{x:Reference ...} -> returns just a reference of an object it doesn't create that "bridge" between two properties like binding would do. Behind all that a service is being used that searches for the given name in a specific scope which is usually the window itself.

{Binding ElementName="..." } -> first of all it creates that binding object then it searches for the object name but not by using the same technique under the hood as x:Reference. The search algorithm moves up and/or down in VisualTree to find the desired element. Therefore a functional VisualTree is always needed. As example when used inside a Non-UiElement, it won't work. In the end the Binding stays and does its daily bread.

This won't work:

<StackPanel>
<Button x:name="bttn1" Visibility="Hidden">Click me</Button>
<DataGrid>
<DataGrid.Columns>
<DataGridTextColumn Visibility="{Binding ElementName=bttn1, Path=DataContext.Visibility}"/>
....

This works:

<StackPanel>
<Button x:name="bttn1" Visibility="Hidden">Click me</Button>
<DataGrid>
<DataGrid.Columns>
<DataGridTextColumn Visibility="{Binding Source={x:Reference bttn1} Path=DataContext.Visibility}"/>
....

Sort of like that :)

最新文章

  1. 【Python】range和xrange区别
  2. HTTP协议 (四) 缓存
  3. python 中接口的实现
  4. iOS : 静态库制作
  5. 利用Meida Service的Java SDK来调用Azure Media Services的Index V2实现视频字幕自动识别
  6. jquery如何实现domReady和onload判断的
  7. [转载]Jquery Form插件表单参数
  8. [LeetCode OJ] Decode Ways
  9. your local changes would be overwritten by merge. commit stash or revert them to proceed. view them
  10. udacity/CarND-Path-Planning-Project 工程详细配置过程——吐血整理
  11. IT男的别样人生,爱折腾,竟然辞职跑丽江去了
  12. RF自动化测试
  13. SQL审计 Yearning 介绍(SQL审核平台)
  14. Linux下创建和删除软、硬链接 可临时处理空间不足
  15. Window 任务栏清除历史记录
  16. 初探nginx负载均衡配置
  17. sqoop快速入门
  18. 如何自定义Tomcat Realm实现我们的用户认证需求
  19. PAT甲题题解-1042. Shuffling Machine (20)-模拟
  20. Java:多线程,CountDownLatch同步器

热门文章

  1. E20190225-hm
  2. 环形文字 + css3制作图形 + animation无限正反旋转的一个小demo
  3. C++函数返回值与引用
  4. [原创]内网渗透专用SSH连接工具sshcmd/sshshell/ssh密码破解以及Kali开启SSH
  5. 在指定的ChartArea中显示Series
  6. C语言提高代码效率的几种方法
  7. bzoj1475:方格取数
  8. max函数的用法
  9. 相册选择头像或者拍照 上传头像以NSData 图片二进制格式 表单上传
  10. mac下启动lnmp的方式