Skip to content

Instantly share code, notes, and snippets.

@einarwh
Created May 2, 2012 20:57
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 einarwh/2580441 to your computer and use it in GitHub Desktop.
Save einarwh/2580441 to your computer and use it in GitHub Desktop.
Implementing INotifyPropertyChanged by hand.
public class PersonViewModel : INotifyPropertyChanged
{
private string _name;
public event PropertyChangedEventHandler PropertyChanged;
public string Name
{
get
{
return _name;
}
set
{
_name = value;
NotifyViewableProperty("Name");
}
}
private void NotifyViewableProperty(string propertyName)
{
var propertyChanged = this.PropertyChanged;
if (propertyChanged != null)
{
propertyChanged.Invoke(this,
new PropertyChangedEventArgs(propertyName));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment