public void Start(bool hasActivator) { if (hasActivator) { if (_styledProperty is object) { _subscription = _target.Bind(_styledProperty, this, BindingPriority.StyleTrigger); } else { _subscription = _target.Bind(_directProperty !, this); } } else { if (_styledProperty is object) { _subscription = _target.SetValue(_styledProperty, _value, BindingPriority.Style); } else { _target.SetValue(_directProperty !, _value); } } }
/// <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); } }
/// <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); } }
public void Attach(IStyleable control) { var description = "Style " + this.Selector.ToString(); var match = this.Selector.Match(control); if (match.ImmediateResult.HasValue) { if (match.ImmediateResult == true) { foreach (Setter setter in this.Setters) { if (setter.Source != null && setter.Value != null) { throw new InvalidOperationException("Cannot set both Source and Value on a Setter."); } if (setter.Source == null) { control.SetValue(setter.Property, setter.Value, BindingPriority.Style); } else { control.Bind(setter.Property, setter.Source, BindingPriority.Style); } } } } else { foreach (Setter setter in this.Setters) { if (setter.Source != null && setter.Value != null) { throw new InvalidOperationException("Cannot set both Source and Value on a Setter."); } StyleBinding binding; if (setter.Source == null) { binding = new StyleBinding(match.ObservableResult, setter.Value, description); } else { binding = new StyleBinding(match.ObservableResult, setter.Source, description); } control.Bind(setter.Property, binding, BindingPriority.StyleTrigger); } } }
/// <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) { Contract.Requires <ArgumentNullException>(control != null); var description = style?.ToString(); if (Property == null) { throw new InvalidOperationException("Setter.Property must be set."); } var binding = Value as IBinding; if (binding != null) { if (activator == null) { control.Bind(Property, binding); } else { var subject = binding.CreateSubject(control, Property); var activated = new ActivatedSubject(activator, subject, description); Bind(control, Property, binding, activated); } } else { if (activator == null) { control.SetValue(Property, Value, BindingPriority.Style); } else { var activated = new ActivatedValue(activator, Value, description); control.Bind(Property, activated, BindingPriority.StyleTrigger); } } }
/// <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) { Contract.Requires<ArgumentNullException>(control != null); var description = style?.ToString(); if (Property == null) { throw new InvalidOperationException("Setter.Property must be set."); } var binding = Value as IBinding; if (binding != null) { if (activator == null) { control.Bind(Property, binding); } else { var subject = binding.CreateSubject(control, Property); var activated = new ActivatedSubject(activator, subject, description); Bind(control, Property, binding, activated); } } else { if (activator == null) { control.SetValue(Property, Value, BindingPriority.Style); } else { var activated = new ActivatedValue(activator, Value, description); control.Bind(Property, activated, BindingPriority.StyleTrigger); } } }