请教INotifyPropertyChanged问题
1个回答
展开全部
InotifyPropertyChanged接口实现分一下几个步骤:
1、定义了一个类,实现接口,实现了绑定和数据的同步(代码如下)
public class person : IMyPropertyChanged
{
private string _name;
public string Name
{
get
{
return _name;
}
set
{
if (value != _name)
{
_name = value;
//when changed ,notice
NotifyChanged(Name);
}
}
}
}
public class IMyPropertyChanged : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public void NotifyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
1、定义了一个类,实现接口,实现了绑定和数据的同步(代码如下)
public class person : IMyPropertyChanged
{
private string _name;
public string Name
{
get
{
return _name;
}
set
{
if (value != _name)
{
_name = value;
//when changed ,notice
NotifyChanged(Name);
}
}
}
}
public class IMyPropertyChanged : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public void NotifyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询