summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.iOS
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Platform.iOS')
-rw-r--r--Xamarin.Forms.Platform.iOS/NativeBindingService.cs39
-rw-r--r--Xamarin.Forms.Platform.iOS/NativeValueConverterService.cs20
-rw-r--r--Xamarin.Forms.Platform.iOS/Xamarin.Forms.Platform.iOS.csproj4
3 files changed, 62 insertions, 1 deletions
diff --git a/Xamarin.Forms.Platform.iOS/NativeBindingService.cs b/Xamarin.Forms.Platform.iOS/NativeBindingService.cs
new file mode 100644
index 00000000..3756e2f0
--- /dev/null
+++ b/Xamarin.Forms.Platform.iOS/NativeBindingService.cs
@@ -0,0 +1,39 @@
+using System;
+using UIKit;
+
+[assembly: Xamarin.Forms.Dependency(typeof(Xamarin.Forms.Platform.iOS.NativeBindingService))]
+
+namespace Xamarin.Forms.Platform.iOS
+{
+ class NativeBindingService : Xaml.INativeBindingService
+ {
+ public bool TrySetBinding(object target, string propertyName, BindingBase binding)
+ {
+ var view = target as UIView;
+ if (view == null)
+ return false;
+ if (target.GetType().GetProperty(propertyName)?.GetMethod == null)
+ return false;
+ view.SetBinding(propertyName, binding);
+ return true;
+ }
+
+ public bool TrySetBinding(object target, BindableProperty property, BindingBase binding)
+ {
+ var view = target as UIView;
+ if (view == null)
+ return false;
+ view.SetBinding(property, binding);
+ return true;
+ }
+
+ public bool TrySetValue(object target, BindableProperty property, object value)
+ {
+ var view = target as UIView;
+ if (view == null)
+ return false;
+ view.SetValue(property, value);
+ return true;
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Platform.iOS/NativeValueConverterService.cs b/Xamarin.Forms.Platform.iOS/NativeValueConverterService.cs
new file mode 100644
index 00000000..9e20e045
--- /dev/null
+++ b/Xamarin.Forms.Platform.iOS/NativeValueConverterService.cs
@@ -0,0 +1,20 @@
+using System;
+using UIKit;
+
+[assembly: Xamarin.Forms.Dependency(typeof(Xamarin.Forms.Platform.iOS.NativeValueConverterService))]
+
+namespace Xamarin.Forms.Platform.iOS
+{
+ class NativeValueConverterService : Xaml.INativeValueConverterService
+ {
+ public bool ConvertTo(object value, Type toType, out object nativeValue)
+ {
+ nativeValue = null;
+ if (typeof(UIView).IsInstanceOfType(value) && toType.IsAssignableFrom(typeof(View))) {
+ nativeValue = ((UIView)value).ToView();
+ return true;
+ }
+ return false;
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Platform.iOS/Xamarin.Forms.Platform.iOS.csproj b/Xamarin.Forms.Platform.iOS/Xamarin.Forms.Platform.iOS.csproj
index 8fde4c81..e31aa3ac 100644
--- a/Xamarin.Forms.Platform.iOS/Xamarin.Forms.Platform.iOS.csproj
+++ b/Xamarin.Forms.Platform.iOS/Xamarin.Forms.Platform.iOS.csproj
@@ -150,6 +150,8 @@
<Compile Include="IOSAppLinks.cs" />
<Compile Include="NativeViewPropertyListener.cs" />
<Compile Include="Extensions\LayoutExtensions.cs" />
+ <Compile Include="NativeValueConverterService.cs" />
+ <Compile Include="NativeBindingService.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\StringResources.ar.resx" />
@@ -205,4 +207,4 @@
<Link>Properties\GlobalAssemblyInfo.cs</Link>
</Compile>
</ItemGroup>
-</Project> \ No newline at end of file
+</Project>