I want to find out when the PropertyChanged event handler is set in my base class.
Both Debug.Print("Is Null") and Debug.Print("not null") get hit. So it must get set somewhere. How do I find that out?
A search for PropertyChanged does not reveal code that subscribes to the ebvent.
public abstract class NonPersistentObjectBase : INotifyPropertyChanged, IObjectSpaceLink {
public event PropertyChangedEventHandler PropertyChanged; // how do I break here
protected void OnPropertyChanged(string propertyName) {
if(PropertyChanged != null) {
Debug.Print("not null"); // gets hit after I click save
}
else {
Debug.Print("Is Null"); //gets hit
}
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
protected void SetPropertyValue<T>(string name, ref T field, T value) {
if(!Equals(field, value)) {
field = value;
OnPropertyChanged(name);
}
}
I added a private event as per Olivier's suggestion but am unsure how to call it. I tried assigning it in the constructor
private event PropertyChangedEventHandler PropertyChangedAdd {
add => PropertyChanged += value;
remove => PropertyChanged -= value;
}