ViewModelBase class


/ Published in: C#
Save to your folder(s)

This class can be used as a base class for ViewModel-classes used in a MVVM design pattern.


Copy this code and paste it in your HTML
  1. public class ViewModelBase : INotifyPropertyChanged
  2. {
  3. #region INotifyPropertyChanged Members
  4.  
  5. public event PropertyChangedEventHandler PropertyChanged;
  6.  
  7. public void NotifyChanged(string propertyName)
  8. {
  9. if (string.IsNullOrEmpty(propertyName))
  10. throw new ArgumentNullException("propertyName");
  11.  
  12. if (PropertyChanged != null)
  13. PropertyChanged(this, new PropertyChangedEventArgspropertyName));
  14. }
  15.  
  16. #endregion
  17. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.