Skip to content

Instantly share code, notes, and snippets.

Created February 25, 2014 23:54
Show Gist options
  • Save anonymous/cdf5f4148953a64d39dc to your computer and use it in GitHub Desktop.
Save anonymous/cdf5f4148953a64d39dc to your computer and use it in GitHub Desktop.
public class Demo : INotifyPropertyChanged
{
protected void SetValue<T>(T value, ref T container, [CallerMemberName] string propertyName = "")
{
if (value.Equals(container))
return;
container = value;
OnPropertyChanged(propertyName);
}
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(string propertyName)
{
var pc = PropertyChanged;
if (pc != null)
pc.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
public class ConcreteDemo : Demo
{
private string _value;
public string Value
{
get { return _value; }
set { SetValue(value, ref _value); }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment