Skip to content

Instantly share code, notes, and snippets.

@icebeam7
Created June 13, 2020 17:10
Show Gist options
  • Save icebeam7/7a9f6865169027b09b5e0cc12c151950 to your computer and use it in GitHub Desktop.
Save icebeam7/7a9f6865169027b09b5e0cc12c151950 to your computer and use it in GitHub Desktop.
BaseViewModel.cs code snippet
public class BaseViewModel : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged([CallerMemberName] string propertyName = "")
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
protected void SetValue<T>(ref T field, T value, [CallerMemberName] string propertyName = null)
{
if (EqualityComparer<T>.Default.Equals(field, value))
return;
field = value;
OnPropertyChanged(propertyName);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment