summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPawel Andruszkiewicz <p.andruszkie@samsung.com>2017-01-26 12:14:55 (GMT)
committerPawel Andruszkiewicz <p.andruszkie@samsung.com>2017-02-03 08:28:58 (GMT)
commit8d09bf33c46c2fecd407b7b4dabd1f83adec5459 (patch)
tree016209e63af1b1554c7f6770d5041473e5c2cbee
parentb4bd94fdd7c3be60a36e6965016d2a6ab3e01ef5 (diff)
downloadxamarin-forms-8d09bf33c46c2fecd407b7b4dabd1f83adec5459.zip
xamarin-forms-8d09bf33c46c2fecd407b7b4dabd1f83adec5459.tar.gz
xamarin-forms-8d09bf33c46c2fecd407b7b4dabd1f83adec5459.tar.bz2
Add support for NativeViews specified in XAMLrefs/changes/52/112152/3
See: https://developer.xamarin.com/guides/xamarin-forms/user-interface/native-views/ Change-Id: I0a4315cccdaa208585f417db4f91240555a64a47 Signed-off-by: Pawel Andruszkiewicz <p.andruszkie@samsung.com>
-rw-r--r--Xamarin.Forms.Platform.Tizen/EvasObjectWrapper.cs10
-rw-r--r--Xamarin.Forms.Platform.Tizen/Extensions/NativeBindingExtensions.cs35
-rw-r--r--Xamarin.Forms.Platform.Tizen/NativeBindingService.cs38
-rw-r--r--Xamarin.Forms.Platform.Tizen/NativeValueConverterService.cs20
-rw-r--r--Xamarin.Forms.Platform.Tizen/Properties/AssemblyInfo.cs2
-rw-r--r--Xamarin.Forms.Platform.Tizen/Xamarin.Forms.Platform.Tizen.csproj3
6 files changed, 108 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.Tizen/EvasObjectWrapper.cs b/Xamarin.Forms.Platform.Tizen/EvasObjectWrapper.cs
index 97cf77f..526c473 100644
--- a/Xamarin.Forms.Platform.Tizen/EvasObjectWrapper.cs
+++ b/Xamarin.Forms.Platform.Tizen/EvasObjectWrapper.cs
@@ -11,6 +11,8 @@ namespace Xamarin.Forms.Platform.Tizen
{
EvasObject = obj;
MeasureDelegate = measureDelegate;
+
+ obj.TransferBindablePropertiesToWrapper(this);
}
public EvasObject EvasObject
@@ -20,5 +22,13 @@ namespace Xamarin.Forms.Platform.Tizen
}
public MeasureDelegate MeasureDelegate { get; }
+
+ protected override void OnBindingContextChanged()
+ {
+ // TODO: we should provide a delegate to obtain children of a Container object,
+ // however currently there is no way to get the list of children
+ EvasObject.SetBindingContext(BindingContext);
+ base.OnBindingContextChanged();
+ }
}
}
diff --git a/Xamarin.Forms.Platform.Tizen/Extensions/NativeBindingExtensions.cs b/Xamarin.Forms.Platform.Tizen/Extensions/NativeBindingExtensions.cs
new file mode 100644
index 0000000..b04894b
--- /dev/null
+++ b/Xamarin.Forms.Platform.Tizen/Extensions/NativeBindingExtensions.cs
@@ -0,0 +1,35 @@
+using System;
+using System.Collections.Generic;
+
+using EObject = ElmSharp.EvasObject;
+
+namespace Xamarin.Forms.Platform.Tizen
+{
+ public static class NativeBindingExtensions
+ {
+ public static void SetBinding(this EObject view, string propertyName, BindingBase binding, string updateSourceEventName = null)
+ {
+ NativeBindingHelpers.SetBinding(view, propertyName, binding, updateSourceEventName);
+ }
+
+ public static void SetBinding(this EObject view, BindableProperty targetProperty, BindingBase binding)
+ {
+ NativeBindingHelpers.SetBinding(view, targetProperty, binding);
+ }
+
+ public static void SetValue(this EObject target, BindableProperty targetProperty, object value)
+ {
+ NativeBindingHelpers.SetValue(target, targetProperty, value);
+ }
+
+ public static void SetBindingContext(this EObject target, object bindingContext, Func<EObject, IEnumerable<EObject>> getChildren = null)
+ {
+ NativeBindingHelpers.SetBindingContext(target, bindingContext, getChildren);
+ }
+
+ internal static void TransferBindablePropertiesToWrapper(this EObject target, View wrapper)
+ {
+ NativeBindingHelpers.TransferBindablePropertiesToWrapper(target, wrapper);
+ }
+ }
+}
diff --git a/Xamarin.Forms.Platform.Tizen/NativeBindingService.cs b/Xamarin.Forms.Platform.Tizen/NativeBindingService.cs
new file mode 100644
index 0000000..945726e
--- /dev/null
+++ b/Xamarin.Forms.Platform.Tizen/NativeBindingService.cs
@@ -0,0 +1,38 @@
+using System;
+
+using EObject = ElmSharp.EvasObject;
+
+namespace Xamarin.Forms.Platform.Tizen
+{
+ class NativeBindingService : Xaml.INativeBindingService
+ {
+ public bool TrySetBinding(object target, string propertyName, BindingBase binding)
+ {
+ var view = target as EObject;
+ 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 EObject;
+ if (view == null)
+ return false;
+ view.SetBinding(property, binding);
+ return true;
+ }
+
+ public bool TrySetValue(object target, BindableProperty property, object value)
+ {
+ var view = target as EObject;
+ if (view == null)
+ return false;
+ view.SetValue(property, value);
+ return true;
+ }
+ }
+}
diff --git a/Xamarin.Forms.Platform.Tizen/NativeValueConverterService.cs b/Xamarin.Forms.Platform.Tizen/NativeValueConverterService.cs
new file mode 100644
index 0000000..956079e
--- /dev/null
+++ b/Xamarin.Forms.Platform.Tizen/NativeValueConverterService.cs
@@ -0,0 +1,20 @@
+using System;
+
+using EObject = ElmSharp.EvasObject;
+
+namespace Xamarin.Forms.Platform.Tizen
+{
+ class NativeValueConverterService : Xaml.INativeValueConverterService
+ {
+ public bool ConvertTo(object value, Type toType, out object nativeValue)
+ {
+ nativeValue = null;
+ if (typeof(EObject).IsInstanceOfType(value) && toType.IsAssignableFrom(typeof(View)))
+ {
+ nativeValue = ((EObject)value).ToView();
+ return true;
+ }
+ return false;
+ }
+ }
+}
diff --git a/Xamarin.Forms.Platform.Tizen/Properties/AssemblyInfo.cs b/Xamarin.Forms.Platform.Tizen/Properties/AssemblyInfo.cs
index 37e0221..0b7977f 100644
--- a/Xamarin.Forms.Platform.Tizen/Properties/AssemblyInfo.cs
+++ b/Xamarin.Forms.Platform.Tizen/Properties/AssemblyInfo.cs
@@ -19,6 +19,8 @@ using Xamarin.Forms.Platform.Tizen;
[assembly: Xamarin.Forms.Dependency(typeof(ResourcesProvider))]
[assembly: Xamarin.Forms.Dependency(typeof(Deserializer))]
+[assembly: Xamarin.Forms.Dependency(typeof(NativeBindingService))]
+[assembly: Xamarin.Forms.Dependency(typeof(NativeValueConverterService))]
[assembly: ExportRenderer(typeof(Layout), typeof(LayoutRenderer))]
[assembly: ExportRenderer(typeof(ScrollView), typeof(ScrollViewRenderer))]
diff --git a/Xamarin.Forms.Platform.Tizen/Xamarin.Forms.Platform.Tizen.csproj b/Xamarin.Forms.Platform.Tizen/Xamarin.Forms.Platform.Tizen.csproj
index 012512b..5c8ac95 100644
--- a/Xamarin.Forms.Platform.Tizen/Xamarin.Forms.Platform.Tizen.csproj
+++ b/Xamarin.Forms.Platform.Tizen/Xamarin.Forms.Platform.Tizen.csproj
@@ -51,6 +51,7 @@
<Compile Include="Extensions\ColorExtensions.cs" />
<Compile Include="Extensions\KeyboardExtensions.cs" />
<Compile Include="Extensions\LayoutExtensions.cs" />
+ <Compile Include="Extensions\NativeBindingExtensions.cs" />
<Compile Include="Extensions\ScrollToPositionExtensions.cs" />
<Compile Include="Extensions\TextAlignmentExtensions.cs" />
<Compile Include="Forms.cs" />
@@ -91,6 +92,8 @@
<Compile Include="Native\TextHelper.cs" />
<Compile Include="Native\TimePicker.cs" />
<Compile Include="Native\Window.cs" />
+ <Compile Include="NativeBindingService.cs" />
+ <Compile Include="NativeValueConverterService.cs" />
<Compile Include="Platform.cs" />
<Compile Include="PlatformEffect.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />