using System.ComponentModel; using System.Runtime.CompilerServices; namespace eSuite.WorkBench.WpfHelper { /// /// Inherit from this base class to have the Interfaces used for WPF implemented. This will allow you to save time when implementation properties on your view model. /// Just call OnPropertyChanging before changing the value of your property, then call OnPropertyChanged after the value has been changed. /// public class ViewModelBase : INotifyPropertyChanging, INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; public event PropertyChangingEventHandler PropertyChanging; /// /// Call this immediately after changing the value of your property /// /// Please leave this blank it will be auto populated protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } /// /// Call this immediately before changing the value of your property /// /// Please leave this blank it will be auto populated protected virtual void OnPropertyChanging([CallerMemberName] string propertyName = null) { if (PropertyChanging != null) { PropertyChanging(this, new PropertyChangingEventArgs(propertyName)); } } } }