关于textbox的数据绑定,使用实体类进行绑定时,修改了实体类属性要即时显示到TEXTBOX上
代码
class Entity:INotifyPropertyChanged
{
private string field;
public string Field
{
get { return field; }
set
{
field = value;
SendChangeInfo("Field");
}
}
private void SendChangeInfo(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
#region INotifyPropertyChanged Members
public event PropertyChangedEventHandler PropertyChanged;
#endregion
}