Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can use the Dependency Property changed callback for PropA and PropB to set the value for PropC (don't use the CLR property wrapper for the Dependency Properties as they are never guaranteed to be called). </p> <p>If you have these three DP's</p> <pre><code>public static readonly DependencyProperty PropAProperty = DependencyProperty.Register("PropA", typeof(bool), typeof(MyView), new PropertyMetadata(false, PropAPropertyChanged)); public static readonly DependencyProperty PropBProperty = DependencyProperty.Register("PropB", typeof(bool), typeof(MyView), new PropertyMetadata(false, PropBPropertyChanged)); public static readonly DependencyProperty PropCProperty = DependencyProperty.Register("PropC", typeof(bool), typeof(MyView), new PropertyMetadata(false)); public bool PropA { get { return (bool)this.GetValue(PropAProperty); } set { this.SetValue(PropAProperty, value); } } public bool PropB { get { return (bool)this.GetValue(PropBProperty); } set { this.SetValue(PropBProperty, value); } } public bool PropC { get { return (bool)this.GetValue(PropCProperty); } set { this.SetValue(PropCProperty, value); } } </code></pre> <p>you can use the property changed callback like this</p> <pre><code>private static void PropAPropertyChanged(DependencyObject source, DependencyPropertyChangedEventArgs e) { MyView myView = source as MyView; myView.OnPropChanged(); } private static void PropBPropertyChanged(DependencyObject source, DependencyPropertyChangedEventArgs e) { MyView myView = source as MyView; myView.OnPropChanged(); } public void OnPropChanged() { PropC = PropA || PropB; } </code></pre> <p>This way, you'll always update the value of <code>PropC</code> everytime <code>PropA</code> or <code>PropB</code> changes</p> <p>Also, <code>PropC</code> doesn't need to be a DP, it can be a normal CLR property if you implement <code>INotifyPropertyChanged</code>. Then the implementation can look like this instead</p> <pre><code>public void OnPropChanged() { OnPropertyChanged("PropC"); } public bool PropC { get { return PropA || PropB; } } public event PropertyChangedEventHandler PropertyChanged; private void OnPropertyChanged(string propertyName) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } </code></pre> <p>You could also bind <code>PropC</code> to <code>PropA</code> and <code>PropB</code> with a <code>MultiBinding</code>. Let me know if you want an example of this as well</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload