internal override void SetUp(BindableObject bindable) { if (Binding != null) { bindable.SetBinding(_boundProperty, Binding.Clone()); } }
public static void SetBinding(this BindableObject self, BindableProperty targetProperty, string path, BindingMode mode = BindingMode.Default, IValueConverter converter = null, string stringFormat = null) { if (self == null) { throw new ArgumentNullException("self"); } if (targetProperty == null) { throw new ArgumentNullException("targetProperty"); } var binding = new Binding(path, mode, converter, stringFormat: stringFormat); self.SetBinding(targetProperty, binding); }
internal void Apply(BindableObject target, bool fromStyle = false) { if (target == null) { throw new ArgumentNullException("target"); } if (Property == null) { return; } object originalValue = target.GetValue(Property); if (!Equals(originalValue, Property.DefaultValue)) { _originalValues.Remove(target); _originalValues.Add(target, originalValue); } var dynamicResource = Value as DynamicResource; var binding = Value as BindingBase; if (binding != null) { target.SetBinding(Property, binding.Clone(), fromStyle); } else if (dynamicResource != null) { target.SetDynamicResource(Property, dynamicResource.Key, fromStyle); } else { if (Value is IList <VisualStateGroup> visualStateGroupCollection) { target.SetValue(Property, visualStateGroupCollection.Clone(), fromStyle); } else { target.SetValue(Property, Value, fromStyle); } } }
public static void SetBinding <TSource>(this BindableObject self, BindableProperty targetProperty, Expression <Func <TSource, object> > sourceProperty, BindingMode mode = BindingMode.Default, IValueConverter converter = null, string stringFormat = null) { if (self == null) { throw new ArgumentNullException("self"); } if (targetProperty == null) { throw new ArgumentNullException("targetProperty"); } if (sourceProperty == null) { throw new ArgumentNullException("sourceProperty"); } Binding binding = Binding.Create(sourceProperty, mode, converter, stringFormat: stringFormat); self.SetBinding(targetProperty, binding); }