我想完成一项简单的任务.需要实现textbox lostfocus,当用户输入数据时,只要一个字段被填充并且他到达下一个字段,它就应该在前一个字段上激活验证功能.另外,我正在使用MVVM模式.
所以我有这门课
public class data : INotifyPropertyChanged
{
public string name;
public string Name
{
get
{
return name;
}
set
{
name = value;
OnPropertyChanged("Name");
}
}
public string firstname;
public string FirstName
{
get
{
return firstname;
}
set
{
firstname = value;
OnPropertyChanged("FirstName");
}
}
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(string propertyName)
{
if (this.PropertyChanged != null)
{
// Raise the PropertyChanged event
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
Run Code Online (Sandbox Code Playgroud)
在Viewmodel中我得到了这个
data1 = new data() { …Run Code Online (Sandbox Code Playgroud)