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);
                }

                NativeBindingHelpers.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);
            }

            NativeBindingHelpers.SetBinding(view, propertyName, binding, eventE);
        }
Beispiel #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))
            {
                NativeBindingHelpers.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
            }

            NativeBindingHelpers.SetBinding(view, propertyName, bindingBase, nativePropertyListener);
        }
Beispiel #3
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))
			{
				NativeBindingHelpers.SetBinding(view, propertyName, bindingBase, updateSourceEventName);
				return;
			}

			NativeViewPropertyListener nativePropertyListener = null;
			if (bindingBase.Mode == BindingMode.TwoWay) {
				nativePropertyListener = new NativeViewPropertyListener(propertyName);
				view.AddObserver(nativePropertyListener, propertyName, 0, IntPtr.Zero);
			}

			NativeBindingHelpers.SetBinding(view, propertyName, bindingBase, nativePropertyListener);
		}
 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 SetBinding(this MockNativeView target, BindableProperty targetProperty, BindingBase binding)
 {
     NativeBindingHelpers.SetBinding(target, targetProperty, binding);
 }
 internal static void SetBinding(this MockNativeView target, string targetProperty, BindingBase binding, INotifyPropertyChanged propertyChanged)
 {
     NativeBindingHelpers.SetBinding(target, targetProperty, binding, propertyChanged);
 }
 public static void SetBinding(this MockNativeView target, string targetProperty, BindingBase binding, string updateSourceEventName = null)
 {
     NativeBindingHelpers.SetBinding(target, targetProperty, binding, updateSourceEventName);
 }
Beispiel #9
0
 public static void SetBinding(this UIView self, BindableProperty targetProperty, BindingBase binding)
 {
     NativeBindingHelpers.SetBinding(self, targetProperty, binding);
 }
 public static void SetBinding(this FrameworkElement view, BindableProperty targetProperty, BindingBase binding)
 {
     NativeBindingHelpers.SetBinding(view, targetProperty, binding);
 }
 public static void SetBinding(this global::Android.Views.View view, string propertyName, BindingBase binding, string updateSourceEventName = null)
 {
     NativeBindingHelpers.SetBinding(view, propertyName, binding, updateSourceEventName);
 }
 public static void SetBinding(this global::Android.Views.View view, BindableProperty targetProperty, BindingBase binding)
 {
     NativeBindingHelpers.SetBinding(view, targetProperty, binding);
 }