Hi
I want to create a special DataTrigger inheriting the TriggerBase<FrameworkElement>. Just similar to theDataTrigger, a property of type BindingBase has been defined in theMyDataTrigger class.
How can I listen to it in order to trace its changes?
public class MyDataTrigger : TriggerBase<FrameworkElement> { ... /// <summary> /// [Wrapper property for BindingProperty] /// <para> /// Gets or sets the binding that produces the /// property value of the data object. /// </para> /// </summary> 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)); }
More Info:
The main problem is that I don't know how to find the BindingBase associatedDependencyProperty. I know how to listen to a DP;
void ListenToDP(object component, DependencyProperty dp) { DependencyPropertyDescriptor dpDescriptor = DependencyPropertyDescriptor.FromProperty(dp, component.GetType()); dpDescriptor.AddValueChanged(component, DPListener_ValueChanged); }
Where DPListener_ValueChanged is an EventHandler delegate. Here, thecomponent parameter value is this.AssociatedObject.