summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKangho Hur <kangho.hur@samsung.com>2017-02-06 16:43:24 -0800
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>2017-02-06 16:43:24 -0800
commit832294236c52463ba581e19f9dd1592381cca4d5 (patch)
treec285352714c912bd5c5f4c6265d5a84a53a7e871
parent55c5428629000fe9c7b8fbdb491869711def44f9 (diff)
parent8d09bf33c46c2fecd407b7b4dabd1f83adec5459 (diff)
downloadxamarin-forms-832294236c52463ba581e19f9dd1592381cca4d5.tar.gz
xamarin-forms-832294236c52463ba581e19f9dd1592381cca4d5.tar.bz2
xamarin-forms-832294236c52463ba581e19f9dd1592381cca4d5.zip
Merge "Add support for NativeViews specified in XAML" into tizen
-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 97cf77f0..526c4739 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 00000000..b04894b1
--- /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 00000000..945726eb
--- /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 00000000..956079ea
--- /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 37e0221a..0b7977f6 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 012512b1..5c8ac950 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" />