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
            {
                target.SetValue(Property, Value, fromStyle);
            }
        }
Esempio n. 2
0
 void IStyle.Apply(BindableObject bindable)
 {
     _targets.Add(new WeakReference <BindableObject>(bindable));
     if (BaseResourceKey != null)
     {
         bindable.SetDynamicResource(_basedOnResourceProperty, BaseResourceKey);
     }
     ApplyCore(bindable, BasedOn ?? GetBasedOnResource(bindable));
 }