I see two types of implementation of INotifyPropertyChanged
The first one:
public abstract class ViewModelBase : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) { PropertyChangedEventHandler handler = PropertyChanged; if (handler != null) { handler(this, new PropertyChangedEventArgs(propertyName)); } } }
The second one:
public abstract class ViewModelBase : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; [NotifyPropertyChangedInvocator] protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) { PropertyChangedEventHandler handler = PropertyChanged; if (handler != null) { handler(this, new PropertyChangedEventArgs(propertyName)); } } }
In 2nd one you see there is an extra attribute [NotifyPropertyChangedInvocator]
on the method OnPropertyChanged
In my case both behaves same but what, why and when to use this [NotifyPropertyChangedInvocator]
, what are benefits of this? I've searched on internet but couldn't find any good answer.