title: WPF How to listen to a BindingBase object?
body: <p>I want to create a special <code>DataTrigger</code> inheriting the <code>TriggerBase&lt;FrameworkElement&gt;</code>. Just similar to the <code>DataTrigger</code>, a property of type <code>BindingBase</code> has been defined in the <code>MyDataTrigger</code> class. </p>
  
  <p>How can I listen to it in order to trace its changes?</p>
  
  <pre><code>public class MyDataTrigger : TriggerBase&lt;FrameworkElement&gt;
  {
      ...
  
      /// &lt;summary&gt;
      /// [Wrapper property for BindingProperty]
      /// &lt;para&gt;
      /// Gets or sets the binding that produces the property value of the data object.
      /// &lt;/para&gt;
      /// &lt;/summary&gt;
      public BindingBase Binding
      {
          get { return (BindingBase)GetValue(BindingProperty); }
          set { SetValue(BindingProperty, value); }
      }
  
      public static readonly DependencyProperty BindingProperty =
          DependencyProperty.Register("Binding",
                                      typeof(BindingBase),
                                      typeof(MyDataTrigger),
                                      new FrameworkPropertyMetadata(null));
  
  }
  </code></pre>
  
  <p><strong>Update:</strong></p>
  
  <p>The main problem is that I don't know how to find the <code>BindingBase</code> associated <code>DependencyProperty</code>. I know how to listen to a DP;</p>
  
  <pre><code>void ListenToDP(object component, DependencyProperty dp)
  {
      DependencyPropertyDescriptor dpDescriptor = DependencyPropertyDescriptor.FromProperty(dp, component.GetType());
      dpDescriptor.AddValueChanged(component, DPListener_ValueChanged);
  }
  </code></pre>
  
  <p>Where <code>DPListener_ValueChanged</code> is an <code>EventHandler</code> delegate. Here, the <em>component</em> parameter value is <code>this.AssociatedObject</code>.</p>