September 5, 2008

INotifyPropertyChanged

using System.ComponentModel;
...
public class foo : INotifyPropertyChanged
{
private int _bar;
public int bar
{
get { return _bar; }
set { _bar = value; if (PropertyChanged != null) OnPropertyChanged("bar"); }
}

#region INotifyPropertyChanged Members
public event PropertyChangedEventHandler PropertyChanged;
public void OnPropertyChanged(string str)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(str));
}
}
#endregion
}

No comments:

Post a Comment