Ejemplo n.º 1
0
        public static void SetBinding(this FrameworkElement view, string propertyName, BindingBase bindingBase, string updateSourceEventName = null)
        {
            var binding = bindingBase as Binding;

            updateSourceEventName = updateSourceEventName ?? binding?.UpdateSourceEventName;

            if (IsNullOrEmpty(updateSourceEventName))
            {
                NativePropertyListener nativePropertyListener = null;
                if (bindingBase.Mode == BindingMode.TwoWay)
                {
                    nativePropertyListener = new NativePropertyListener(view, propertyName);
                }

                PlatformBindingHelpers.SetBinding(view, propertyName, bindingBase, nativePropertyListener as INotifyPropertyChanged);
                return;
            }

            NativeEventWrapper eventE = null;

            if (binding.Mode == BindingMode.TwoWay && !(view is INotifyPropertyChanged))
            {
                eventE = new NativeEventWrapper(view, propertyName, updateSourceEventName);
            }

            PlatformBindingHelpers.SetBinding(view, propertyName, binding, eventE);
        }
Ejemplo n.º 2
0
        public static void SetBinding(this UIView view, string propertyName, BindingBase bindingBase,
                                      string updateSourceEventName = null)
        {
            var binding = bindingBase as Binding;

            //This will allow setting bindings from Xaml by reusing the MarkupExtension
            updateSourceEventName = updateSourceEventName ?? binding?.UpdateSourceEventName;

            if (!IsNullOrEmpty(updateSourceEventName))
            {
                PlatformBindingHelpers.SetBinding(view, propertyName, bindingBase, updateSourceEventName);
                return;
            }

            NativeViewPropertyListener nativePropertyListener = null;

            if (bindingBase.Mode == BindingMode.TwoWay)
            {
                nativePropertyListener = new NativeViewPropertyListener(propertyName);
                try
                {
                    //TODO: We need to figure a way to map the value back to the real objectiveC property.
                    //the X.IOS camelcase property name won't work
                    var key      = new Foundation.NSString(propertyName.ToLower());
                    var valueKey = view.ValueForKey(key);
                    if (valueKey != null)
                    {
                        view.AddObserver(nativePropertyListener, key, Foundation.NSKeyValueObservingOptions.New, IntPtr.Zero);
                    }
                }
#if __MOBILE__
                catch (Foundation.MonoTouchException ex)
                {
                    nativePropertyListener = null;
                    if (ex.Name == "NSUnknownKeyException")
                    {
                        System.Diagnostics.Debug.WriteLine("KVO not supported, try specify a UpdateSourceEventName instead.");
                        return;
                    }
                    throw ex;
                }
#else
                catch (Exception ex)
                {
                    throw ex;
                }
#endif
            }

            PlatformBindingHelpers.SetBinding(view, propertyName, bindingBase, nativePropertyListener);
        }
Ejemplo n.º 3
0
 public static void SetBindingContext(this UIView target, object bindingContext,
                                      Func <UIView, IEnumerable <UIView> > getChildren = null)
 {
     PlatformBindingHelpers.SetBindingContext(target, bindingContext, getChildren);
 }
Ejemplo n.º 4
0
 public static void SetBinding(this UIView self, BindableProperty targetProperty, BindingBase binding)
 {
     PlatformBindingHelpers.SetBinding(self, targetProperty, binding);
 }
Ejemplo n.º 5
0
 internal static void TransferbindablePropertiesToWrapper(this FrameworkElement target, View wrapper)
 {
     PlatformBindingHelpers.TransferBindablePropertiesToWrapper(target, wrapper);
 }
Ejemplo n.º 6
0
 public static void SetBinding(this EObject view, BindableProperty targetProperty, BindingBase binding)
 {
     PlatformBindingHelpers.SetBinding(view, targetProperty, binding);
 }
Ejemplo n.º 7
0
 public static void SetBindingContext(this MockPlatformView target, object bindingContext, Func <MockPlatformView, IEnumerable <MockPlatformView> > getChild = null)
 {
     PlatformBindingHelpers.SetBindingContext(target, bindingContext, getChild);
 }
Ejemplo n.º 8
0
 public static void SetBinding(this MockPlatformView target, BindableProperty targetProperty, BindingBase binding)
 {
     PlatformBindingHelpers.SetBinding(target, targetProperty, binding);
 }
Ejemplo n.º 9
0
 public static void SetBinding(this global::Android.Views.View view, string propertyName, BindingBase binding, string updateSourceEventName = null)
 {
     PlatformBindingHelpers.SetBinding(view, propertyName, binding, updateSourceEventName);
 }
Ejemplo n.º 10
0
 internal static void TransferBindablePropertiesToWrapper(this global::Android.Views.View target, View wrapper)
 {
     PlatformBindingHelpers.TransferBindablePropertiesToWrapper(target, wrapper);
 }
Ejemplo n.º 11
0
 public static void SetValue(this global::Android.Views.View target, BindableProperty targetProperty, object value)
 {
     PlatformBindingHelpers.SetValue(target, targetProperty, value);
 }
Ejemplo n.º 12
0
 public static void SetBinding(this global::Android.Views.View view, BindableProperty targetProperty, BindingBase binding)
 {
     PlatformBindingHelpers.SetBinding(view, targetProperty, binding);
 }
Ejemplo n.º 13
0
 public static void SetBinding(this EObject view, string propertyName, BindingBase binding, string updateSourceEventName = null)
 {
     PlatformBindingHelpers.SetBinding(view, propertyName, binding, updateSourceEventName);
 }
Ejemplo n.º 14
0
 internal static void TransferBindablePropertiesToWrapper(this EObject target, View wrapper)
 {
     PlatformBindingHelpers.TransferBindablePropertiesToWrapper(target, wrapper);
 }
Ejemplo n.º 15
0
 public static void SetBinding(this MockPlatformView target, string targetProperty, BindingBase binding, string updateSourceEventName = null)
 {
     PlatformBindingHelpers.SetBinding(target, targetProperty, binding, updateSourceEventName);
 }
Ejemplo n.º 16
0
 internal static void SetBinding(this MockPlatformView target, string targetProperty, BindingBase binding, INotifyPropertyChanged propertyChanged)
 {
     PlatformBindingHelpers.SetBinding(target, targetProperty, binding, propertyChanged);
 }
Ejemplo n.º 17
0
        // TODO MAUI
        //public static void SetBinding(this FrameworkElement view, string propertyName, BindingBase bindingBase, string updateSourceEventName = null)
        //{
        //	var binding = bindingBase as Binding;
        //	updateSourceEventName = updateSourceEventName ?? binding?.UpdateSourceEventName;

        //	if (IsNullOrEmpty(updateSourceEventName))
        //	{
        //		NativePropertyListener nativePropertyListener = null;
        //		if (bindingBase.Mode == BindingMode.TwoWay)
        //			nativePropertyListener = new NativePropertyListener(view, propertyName);

        //		PlatformBindingHelpers.SetBinding(view, propertyName, bindingBase, nativePropertyListener as INotifyPropertyChanged);
        //		return;
        //	}

        //	NativeEventWrapper eventE = null;
        //	if (binding.Mode == BindingMode.TwoWay && !(view is INotifyPropertyChanged))
        //		eventE = new NativeEventWrapper(view, propertyName, updateSourceEventName);

        //	PlatformBindingHelpers.SetBinding(view, propertyName, binding, eventE);
        //}

        public static void SetBinding(this FrameworkElement view, BindableProperty targetProperty, BindingBase binding)
        {
            PlatformBindingHelpers.SetBinding(view, targetProperty, binding);
        }
Ejemplo n.º 18
0
 public static void SetValue(this MockPlatformView target, BindableProperty targetProperty, object value)
 {
     PlatformBindingHelpers.SetValue(target, targetProperty, value);
 }
Ejemplo n.º 19
0
 public static void SetValue(this FrameworkElement target, BindableProperty targetProperty, object value)
 {
     PlatformBindingHelpers.SetValue(target, targetProperty, value);
 }
Ejemplo n.º 20
0
 internal static void TransferbindablePropertiesToWrapper(this MockPlatformView target, MockPlatformViewWrapper wrapper)
 {
     PlatformBindingHelpers.TransferBindablePropertiesToWrapper(target, wrapper);
 }
Ejemplo n.º 21
0
 public static void SetBindingContext(this FrameworkElement target, object bindingContext, Func <FrameworkElement, IEnumerable <FrameworkElement> > getChildren = null)
 {
     PlatformBindingHelpers.SetBindingContext(target, bindingContext, getChildren);
 }