Esempio n. 1
0
 public void Apply(BindableObject bindable)
 {
     ImplicitStyle?.Apply(bindable);
     if (ClassStyles != null)
     {
         foreach (var classStyle in ClassStyles)
         {
             ((IStyle)classStyle)?.Apply(bindable);
         }
     }
     Style?.Apply(bindable);
 }
Esempio n. 2
0
        void SetStyle(IStyle implicitStyle, IList <Style> classStyles, IStyle style)
        {
            bool shouldReApplyStyle         = implicitStyle != ImplicitStyle || classStyles != ClassStyles || Style != style;
            bool shouldReApplyClassStyle    = implicitStyle != ImplicitStyle || classStyles != ClassStyles;
            bool shouldReApplyImplicitStyle = implicitStyle != ImplicitStyle && (Style as Style == null || ((Style)Style).CanCascade);

            if (shouldReApplyStyle)
            {
                Style?.UnApply(Target);
            }
            if (shouldReApplyClassStyle && ClassStyles != null)
            {
                foreach (var classStyle in ClassStyles)
                {
                    ((IStyle)classStyle)?.UnApply(Target);
                }
            }
            if (shouldReApplyImplicitStyle)
            {
                ImplicitStyle?.UnApply(Target);
            }

            _implicitStyle = implicitStyle;
            _classStyles   = classStyles;
            _style         = style;

            if (shouldReApplyImplicitStyle)
            {
                ImplicitStyle?.Apply(Target);
            }
            if (shouldReApplyClassStyle && ClassStyles != null)
            {
                foreach (var classStyle in ClassStyles)
                {
                    ((IStyle)classStyle)?.Apply(Target);
                }
            }
            if (shouldReApplyStyle)
            {
                Style?.Apply(Target);
            }
        }