Created
May 2, 2012 20:57
-
-
Save einarwh/2580441 to your computer and use it in GitHub Desktop.
Implementing INotifyPropertyChanged by hand.
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 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