我有xaml文件:
<TextBox Text="{Binding Student.SName, Mode=TwoWay}"/>
<TextBox Text="{Binding Student.Name, Mode=TwoWay}"/>
我对这个xaml文件的定义:
public Model.Student Student { get; set; }
属性中的Student
类:
public class Student : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
private string _SName;
private string _Name;
public string SName
{
get { return _SName; }
set
{
if (_SName != value)
{
_SName = value;
OnPropertyChanged("SName");
}
}
}
public string Name
{
get { return _Name; }
set
{
if (_Name != value)
{
_Name = value;
OnPropertyChanged("Name");
}
}
}
}
如何在输入文字时自动更改学生资产中的值?