예제 #1
0
        internal void Apply(BindableObject target, bool fromStyle = false)
        {
            if (target == null)
            {
                throw new ArgumentNullException(nameof(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
            {
                target.SetValue(Property, Value, fromStyle);
            }
        }
예제 #2
0
 internal override void SetUp(BindableObject bindable)
 {
     if (Binding != null)
     {
         bindable.SetBinding(boundProperty, Binding.Clone());
     }
 }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }