Example #1
0
 bool ValidateBasedOn(XamlStyle value)
 {
     if (value == null)
     {
         return(true);
     }
     return(value.TargetType.IsAssignableFrom(TargetType));
 }
Example #2
0
        static void OnBasedOnResourceChanged(BindableObject bindable, object oldValue, object newValue)
        {
            XamlStyle style = (bindable as View)?.XamlStyle;

            if (style == null)
            {
                return;
            }
            style.UnApplyCore(bindable, (XamlStyle)oldValue);
            style.ApplyCore(bindable, (XamlStyle)newValue);
        }
Example #3
0
        void UnApplyCore(BindableObject bindable, XamlStyle basedOn)
        {
            ((AttachedCollection <TriggerBase>)Triggers).DetachFrom(bindable);
            ((AttachedCollection <Behavior>)Behaviors).DetachFrom(bindable);
            foreach (Setter setter in Setters)
            {
                setter.UnApply(bindable, true);
            }

            if (basedOn != null)
            {
                ((IStyle)basedOn).UnApply(bindable);
            }
        }
Example #4
0
        void BasedOnChanged(XamlStyle oldValue, XamlStyle newValue)
        {
            foreach (WeakReference <BindableObject> bindableRef in targets)
            {
                BindableObject bindable;
                if (!bindableRef.TryGetTarget(out bindable))
                {
                    continue;
                }

                UnApplyCore(bindable, oldValue);
                ApplyCore(bindable, newValue);
            }
        }
Example #5
0
        void ApplyCore(BindableObject bindable, XamlStyle basedOn)
        {
            if (basedOn != null)
            {
                ((IStyle)basedOn).Apply(bindable);
            }

            foreach (Setter setter in Setters)
            {
                setter.Apply(bindable, true);
            }
            ((AttachedCollection <Behavior>)Behaviors).AttachTo(bindable);
            ((AttachedCollection <TriggerBase>)Triggers).AttachTo(bindable);
        }
 internal void Add(XamlStyle style)
 {
     if (string.IsNullOrEmpty(style.Class))
     {
         Add(style.TargetType.FullName, style);
     }
     else
     {
         IList <XamlStyle> classes;
         object            outclasses;
         if (!TryGetValue(XamlStyle.StyleClassPrefix + style.Class, out outclasses) || (classes = outclasses as IList <XamlStyle>) == null)
         {
             classes = new List <XamlStyle>();
         }
         classes.Add(style);
         this[XamlStyle.StyleClassPrefix + style.Class] = classes;
     }
 }