INotifyPropertyChanged
namespace Views
{
public abstract class ViewBase:UserControl,INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected void RasePropertyChanged(string proName)
{
if(this.PropertyChanged != null)
{
PropertyChanged(this,new PropertyChangedEventArgs(proName));
}
}
}
public abstract class WindowViewBase:BlankWindow,INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected void RaisePropertyChanged(string propName)
{
if(this.PropertyChanged!=null)
{
PropertyChanged(this,new PropertyChangedEventsArgs(proName));
}
}
}
}
实现ViewBase这个接口,就可以简写绑定。
public string name;
publiv string Name
{
get{ return name; }
set
{
name = value;
this.RaisePropertyChanged("Name");
}
}