What is the purpose of INotifyPropertyChanged. I know this event is fired whenever a property is changed but how can the View/UI knows that this event is fired:
Here is my Customer class that implements the INotifyPropertyChanged event:
public class Customer : INotifyPropertyChanged
{
private string _firstName;
public string LastName { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string propertyName)
{
if(PropertyChanged != null)
PropertyChanged(this,new PropertyChangedEventArgs(propertyName));
}
public string FirstName
{
get { return _firstName; }
set
{
_firstName = value;
OnPropertyChanged("FirstName");
}
}
}
But now how to notify the UI that property has changed. Like when the user assigns null or empty to the first name how can I display a MessageBox on the UI.