WPF 中Binding的2个属性Source与ElementName的区别
来源:互联网 发布:微信美化软件 编辑:程序博客网 时间:2024/04/30 22:35
原文出处:http://www.im47.cn/?p=482
ElementName
The ElementName property is used to reference an object by the name of the object. This is particularly useful in XAML, where you can directly reference other elements defined in XAML.
举例
<StackPanel Background=”Blue”>
<Button x:Name=”refButton” Background=”Orange”/>
<Button Background=”{Binding ElementName=refButton, Path=Background}”/>
</StackPanel>
Source
The Source property is used to specify an object reference on which the binding Path or XPath will be evaluated. The Source property is usually used when the object on which the Binding is set is known and differs from the DataContext.
举例:
<CustomClass1 Property1=”{Binding Source={x:Static DateTime.Now}, Path=Day}”/>
<CustomClass1 Property1=”{Binding Source={StaticResource AnotherElement}, Path=ActualWidth}”/>
简单地说,“ElementName”用于绑定到xaml界面设计中添加的其它控件对象,“Source”用于绑到资源中的对象。
- WPF 中Binding的2个属性Source与ElementName的区别
- wpf数据绑定source和elementname的区别
- WPF中Image控件的Source属性
- 数据绑定之 Source, RelativeSource和ElementName的不同
- WPF中Binding的技巧(一)
- WPF中Binding的技巧(一)
- WPF中Binding的技巧(一)
- WPF中radiobutton 的 data binding方法
- WPF中的binding(八)- 使用ObjectDataProvider对象作为Binding的Source
- 【WPF】binding的使用
- WPF的binding
- WPF Tips: Data Binding Converter一例:bool与IsChecked属性(bool?)之间的转换
- WPF 中PasswordBox控件的Password属性不能Binding问题解决方法
- WPF中Auto与*的区别
- WPF中Auto与*的区别
- WPF中Auto与*的区别
- WPF自定义对象的Binding
- WPF 坑爹的binding
- 分页基本原理(linux0.11)
- 打电话给女友
- 雷军财富超马云100亿美元,马云叹首富位子屁股没坐热
- 【OpenCV学习】Kmean均值聚类对图片进行减色处理
- ACE定时器
- WPF 中Binding的2个属性Source与ElementName的区别
- Find Minimum in Rotated Sorted Array II(LeetCode)
- 花生壳 for linux的安装以及使用
- 哎,我今年28,9岁
- C++11显式转换操作符
- Struts2关于Action的系统训练1
- DB2 SQL300081-08001错误解决办法
- Java以及JS 手机号当中4位用“*”代替
- 跨界的艺术