Skip to content

Instantly share code, notes, and snippets.

@phillipsj
Created July 2, 2014 16:44
Show Gist options
  • Save phillipsj/d28720411ee9320fdc2d to your computer and use it in GitHub Desktop.
Save phillipsj/d28720411ee9320fdc2d to your computer and use it in GitHub Desktop.
INotifyPropertyChane without WPF
public class Child
{
public string ParentPopertyName { get; set; }
}
public class Parent: INotifyPropertyChanged
{
public Parent()
{
this.PropertyChanged += Parent_PropertyChanged;
}
void Parent_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
this._myFavoriteChild.ParentPopertyName = e.PropertyName;
}
public event PropertyChangedEventHandler PropertyChanged;
// This method is called by the Set accessor of each property.
// The CallerMemberName attribute that is applied to the optional propertyName
// parameter causes the property name of the caller to be substituted as an argument.
private void NotifyPropertyChanged([CallerMemberName] String propertyName = "")
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
private Child _myFavoriteChild;
public Child MyFavoriteChild
{
get { return _myFavoriteChild; }
set
{
_myFavoriteChild = value;
NotifyPropertyChanged();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment