开始写wpf笔记,都为小示例1.创建一个类 namespace SimpleBinding} 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.效果 完 相关文章: 2022-02-21 2022-12-23 2021-06-04 2022-12-23 2021-10-18 2022-12-23 2021-08-28 2021-10-19