【实例:对TextBox和Slider进行数据绑定】
<TextBox Text="{Binding Value,Mode=TwoWay,ElementName=slider1}"/>
<Slider Name="slider1" Maxmum="100" , Minmun="0" />
【绑定后台数据】
前台:
<TextBox Name=”txt1" Text="{Binding Name}"/>
<TextBox Name=”txt2" Text="{Binding Age}"/>
<Button Content="修改“ Click="Burron1_Click"/>
类:
public class Person:INotifyPropertyChanged
{
private string _name;
private int _age;
public string Name
{
get { return _name; }
set
{
_name = value;
if(PropertyChanged !=null)
PropertyChanged(this, new PropertyChangedEventArgs("Name") );
}
}
public string Age
{
get { return _age; }
set
{
_age = value;