Пример #1
0
 public void UnApply(BindableObject bindable)
 {
     Style?.UnApply(bindable);
     if (ClassStyles != null)
     {
         foreach (var classStyle in ClassStyles)
         {
             ((IStyle)classStyle)?.UnApply(bindable);
         }
     }
     ImplicitStyle?.UnApply(bindable);
 }
Пример #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);
            }
        }