What is the purpose of INotifyPropertyChanged. I know that this event is fired whenever the property changes, but how can View / UI know 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 user interface that the property has changed. For example, when a user assigns a blank or empty name to the first name, how can I display a MessageBox in the user interface.
tony clifton
source share