Created
April 13, 2020 04:30
-
-
Save zafe/6be0e4e7c7e25dd825ce020d11cd933f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class ViewModelBase : INotifyPropertyChanged | |
{ | |
public event PropertyChangedEventHandler PropertyChanged; | |
protected bool SetProperty<T>(ref T field, T newValue, [CallerMemberName]string propertyName = null) | |
{ | |
if(!EqualityComparer<T>.Default.Equals(field, newValue)) | |
{ | |
field = newValue; | |
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); | |
return true; | |
} | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment