开始写wpf笔记,都为小示例1.创建一个类namespace SimpleBinding{ public class Person { private string _nameProperty = "Joe"; public Person() { } public string Name { get { return _nameProperty; } set { this._nameProperty = value; } } }} 2.在xaml中声明对象(src为注册对象,类似asp.net控件的<asp:xxx的asp一样 <src:Person Name="aaaa" x:Key="xxx" ></src:Person> 3.实行绑定 使用Binding标签对象绑定 <TextBox Width="100" Height="25"> <TextBox.Text> <Binding Source="{StaticResource xxx}" Path="Name"/> </TextBox.Text> </TextBox> 4.使用ObjectDataProvider对象作为数据源对象(注意ObjectType属性为扩展对象类型为scr:Person,如同asp.net控件 上面代码改为<ObjectDataProvider x:Key="myDataSource" ObjectType="{x:Type src:Person}" IsAsynchronous="True" /> 5.更改绑定对象<TextBox Width="100" Height="25"> <TextBox.Text> <Binding Source="{StaticResource myDataSource}" Path="Name"/> </TextBox.Text> </TextBox> 6.效果 完