See: https://developer.xamarin.com/guides/xamarin-forms/user-interface/native-views/
Change-Id: I0a4315cccdaa208585f417db4f91240555a64a47
Signed-off-by: Pawel Andruszkiewicz <p.andruszkie@samsung.com>
{
EvasObject = obj;
MeasureDelegate = measureDelegate;
+
+ obj.TransferBindablePropertiesToWrapper(this);
}
public EvasObject EvasObject
}
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();
+ }
}
}
--- /dev/null
+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);
+ }
+ }
+}
--- /dev/null
+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;
+ }
+ }
+}
--- /dev/null
+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;
+ }
+ }
+}
[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))]
<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" />
<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" />