I was writing a helper class today for WPF and had a IsDirty flag which was firing a PropertyChanged event. However, when I used this in my UI the element that was bound to this flag was not updating.
After a quick look through my code I noticed the following…
private void OnPropertyChanged(string property) { if (null != PropertyChanged) PropertyChanged(null, new PropertyChangedEventArgs(property)); }
I’d mistakenly used null as the first parameter to the PropertyChanged handler. After changing the parameter to this everything started working as expected.
So the moral of the story is – WPF needs both the object raising the notification and the property changed events in order to work its magic.