When handling the PropertyChanged event of an object that implements
INotifyPropertyChanged, one is tempted to write a handler like this:
Strictly speaking, this isn’t entirely correct. According to the documentation
for the PropertyChanged event, “the PropertyChanged event can indicate all
properties on the object have changed by using either null or string.Empty as
the property name in the PropertyChangedEventArgs.” So, you’re forced to write
something like this:
To make checking for this situation a little bit easier, and to increase the
likelihood that we remember to do it, we put together a nice little extension
method on PropertyChangedEventArgs called HasChanged:
Now, proper handling of the PropertyChanged event is as easy as this: