Пример #1
0
 /// <summary>
 /// Applies the setter to the control.
 /// </summary>
 /// <param name="style">The style that is being applied.</param>
 /// <param name="control">The control.</param>
 /// <param name="activator">An optional activator.</param>
 public void Apply(IStyle style, IStyleable control, IObservable <bool> activator)
 {
     if (activator == null)
     {
         control.SetValue(Property, Value, BindingPriority.Style);
     }
     else
     {
         var binding = new StyleBinding(activator, Value, style.ToString());
         control.Bind(Property, binding, BindingPriority.StyleTrigger);
     }
 }
Пример #2
0
        public void Attach(IStyleable control)
        {
            string         description = "Style " + this.Selector.ToString();
            StyleActivator activator   = this.Selector.GetActivator(control);

            if (activator.CurrentValue || !activator.HasCompleted)
            {
                IObservable <bool> observable = activator;

                // If the activator has completed, then we want its value to be true forever.
                // Because of this we can't pass the activator directly as it will complete
                // immediately and remove the binding.
                if (activator.HasCompleted)
                {
                    observable = Observable.Never <bool>().StartWith(true);
                }

                foreach (Setter setter in this.Setters)
                {
                    StyleBinding binding = new StyleBinding(observable, setter.Value, description);
                    control.Bind(setter.Property, binding, this.Selector.Priority);
                }
            }
        }