-
-
Notifications
You must be signed in to change notification settings - Fork 227
ExampleUsage
Simon Cropp edited this page Jul 30, 2012
·
3 revisions
public class Person : INotifyPropertyChanged
{
public string GivenName { get; set; }
public string FamilyName { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
public string FullName
{
get { return GivenName + " " + FamilyName; }
}
}
public class Person : INotifyPropertyChanged
{
private string familyName;
private string givenName;
public event PropertyChangedEventHandler PropertyChanged;
public string FamilyName
{
get
{
return familyName;
}
set
{
if (!Object.Equals(familyName, value))
{
familyName = value;
OnPropertyChanged("FamilyName");
OnPropertyChanged("FullName");
}
}
}
public string GivenName
{
get
{
return givenName;
}
set
{
if (!Object.Equals(givenName, value))
{
givenName = value;
OnPropertyChanged("GivenName");
OnPropertyChanged("FullName");
}
}
}
public string FullName
{
get
{
return GivenName + " " + FamilyName;
}
}
public virtual void OnPropertyChanged(string propertyName)
{
var propertyChanged = PropertyChanged;
if (propertyChanged != null)
{
propertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}