I am implementing INotifyPropertyChanged and as part of that interface I have the member
public event PropertyChangedEventHandler PropertyChanged;
I have the following code for when some property gets changed –
public string FavoriteColor
{
get { return this.favoriteColor; }
set
{
if (value != this.favoriteColor)
{
this.favoriteColor = value;
**if (this.PropertyChanged != null)**
{
this.PropertyChanged(this, new PropertyChangedEventArgs("FavoriteColor"));
}
}
}
}
Now, I have never set the PropertyChanged variable anywhere in my code, yet if I put a breakpoint at this line it shows that PropertyChanged does have a value. So how is it getting set?
If you bind to the property the binding system subscribes to the event.