RelativeSource和AncesorType的使用
如果要绑定到对象上的另一个属性:
{Binding Path=PathToProperty, RelativeSource={RelativeSource Self}}
如果您想获得祖先的属性:
{Binding Path=PathToProperty,
RelativeSource={RelativeSource AncestorType={x:Type typeOfAncestor}}}
如果希望获得模板父级上的属性(因此可以在ControlTemplate中执行双向绑定)
{Binding Path=PathToProperty, RelativeSource={RelativeSource TemplatedParent}}
或者,更短的(这只适用于OneWay绑定):
{TemplateBinding Path=PathToProperty}
<Expander Grid.Row="1"><Expander.Header><StackPanel Orientation="Horizontal"><Rectangle Height="20" Width="8" Fill="#f39800"/><TextBlock Margin="8,0,0,0" Text="业务信息" FontSize="14px" FontFamily="微软雅黑" VerticalAlignment="Cente
RelativeSource和AncesorType的使用相关推荐
- 在WP7下自定义RelativeSource 的Binding
最近老没有时间上来写博文.今天有空来写写上次还没有说完的话题.上一篇提到说说我在WP7应用开发中遇到的 子控件 DataTemplete 中的按钮的命令绑定,刚开始接触似乎是个头疼的问题.那怎么解决呢 ...
- 背水一战 Windows 10 (19) - 绑定: TemplateBinding 绑定, 与 RelativeSource 绑定, 与 StaticResource 绑定...
原文:背水一战 Windows 10 (19) - 绑定: TemplateBinding 绑定, 与 RelativeSource 绑定, 与 StaticResource 绑定 [源码下载] 背水 ...
- 重新想象 Windows 8 Store Apps (52) - 绑定: 与 Element Model Indexer Style RelativeSource 绑定, 以及绑定中的数据转换...
重新想象 Windows 8 Store Apps (52) - 绑定: 与 Element Model Indexer Style RelativeSource 绑定, 以及绑定中的数据转换 原文: ...
- WPF教程(四)RelativeSource属性(转)
WPF教程(四)RelativeSource属性 2018年08月13日 15:11:56 yangwenxue1989 阅读数:749 我们进行Bingding时,如果明确知道数据源的Name,就能 ...
- 为什么WPF在code behind使用RelativeSource的binding会出现错误
不知道是不是有小伙伴遇到过这样的情况.当我们尝试将一个RelativeSource从xaml转到code behind时,原本好好的binding表达式居然出现binding错误. 我们来做个实验,我 ...
- 在WPF中如何使用RelativeSource绑定
在WPF中如何使用RelativeSource绑定 原文: 在WPF中如何使用RelativeSource绑定 在WPF绑定的时候,指定绑定源时,有一种办法是使用RelativeSource. 这种办 ...
- 【WPF】WPF通过RelativeSource绑定父控件的属性
1.后台代码实现绑定父控件的属性 RelativeSource rs = new RelativeSource(RelativeSourceMode.FindAncestor); //设定为离自己控件 ...
- RelativeSource 简述
原文:RelativeSource 简述 RelativeSource实现标记扩展,以描述绑定源相对于绑定目标的位置. <Binding><Binding.RelativeSourc ...
- WPF教程(四)RelativeSource属性
我们进行Bingding时,如果明确知道数据源的Name,就能用Source或者ElementName进行绑定,但是有时候我们需要绑定的数据源可能没有明确的Name,此时我们就需要利用Bingding ...
最新文章
- iOS11开发教程(二十三)iOS11应用视图实现按钮的响应(3)
- 「AI激荡三十年」中的哈工大与王海峰:中国AI如何从贫瘠的孤岛,走向世界?...
- Facebook 宣布改名为Meta,未来重点开发元宇宙!
- FAST300M无线宽带路由器FW300R(从)桥接TPLINK路由器(主)
- SQL Server MYSQL 检查点的好处
- java callback_java——回调机制(callback)
- 视频教程_干货视频教程分享
- 串口和并口通信1-概念
- 复旦大学《高等代数学(第三版)》教材勘误表
- 小程序input绑定输入保存数据
- 微信公众账号查看历史消息
- Python-QQ聊天记录分析-jieba+wordcloud
- h2o api java_H2O框架简介
- 驾驶证期满换证流程(杭州篇)
- U8根据发货单生成销售订单(反向生单)
- python selenium 的使用——alibaba询盘
- 如何使服务器信号加强,增强路由器信号的操作方法
- MGF病毒的利用代码
- Selenium自动化测试框架—简单了解
- 各种国际搜索引擎广告入口