Search code examples
c#wpfxamlreverse-engineering

Find out the recipients of the OnPropertyChanged event in WPF


I am doing reverse ingineering in a project written by some one else. The GUI is made in WPF and has several windows. One class has implemented the INotifyPropertyChanged interface and 2 properties fire the OnPropertyChanged event to signal the data.

My aim is to find out which control profits from this event. How can I find all controls that actually harness the information when the OnPropertyChanged event from the 2 properties is fired?

Looking for all references of the delegate did not lead to any results. There is no explicit registration of this event. I remember vaguely that this connection can be established in the XAML code in WPF using binding, but I don't know enough about WPF find this information on my own.

Any help would be greatly appreciated


Solution

  • Suppose your two properties are named FirstProperty and SecondProperty. Just look in the XAML for binding references to them like:

    {Binding FirstProperty}
    {Binding FirstProperty, ...}
    {Binding [whatever].FirstProperty, ...}
    {Binding ..., Path=FirstProperty, ...}
    {Binding ..., Path=[whatever].FirstProperty, ...}
    

    Controls that use those bindings are the one that will get the PropertyChanged event. For instance, if you find:

    <TextBlock x:Name="myText", Text="{Binding FirstProperty}" />
    

    this means that the above TextBox control will react to FirstProperty changes notified by the PropertyChanged event.