Skip to content

Instantly share code, notes, and snippets.

@tanitanin
Created September 16, 2017 08:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tanitanin/9d4bf2c99d0b48b025e5e6a338b36b4b to your computer and use it in GitHub Desktop.
Save tanitanin/9d4bf2c99d0b48b025e5e6a338b36b4b to your computer and use it in GitHub Desktop.
Observable class to notify event which property changes.
public class Observable : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public void Set<T>(ref T target, T value, [CallerMemberName] string propertyName = null)
{
if (target.Equals(value)) return;
target = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment