Difference between x:Reference and x:Name
{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 :)
Difference between x:Reference and x:Name的更多相关文章
- Recover data from reference electrode via EEGLab 用EEGLab恢复参考电极数据
The data of scanning reference electrode will not show initially. Here is a summary of recovering it ...
- STL迭代器之二:迭代器型别
如果一个迭代器要兼容stl,必须遵循约定,自行以内嵌型别定义的方式定义出相应型别.根据书中介绍,最常用到的迭代器型别有五种:value type,difference type, pointer, r ...
- halcon中variation_model_single实例注释.
* This example shows how to employ the new extensions of HALCON's variation model operators* to perf ...
- php面试题之三——PHP语言基础(基础部分)
三.PHP语言基础 1. strlen( )与 mb_strlen( )的作用分别是什么(新浪网技术部) strlen和mb_strlen都是用于获取字符串长度. strlen只针对单字节编码字符,也 ...
- Git - Tutorial [Lars Vogel]
From: http://www.vogella.com/tutorials/Git/article.html Git - Tutorial Lars Vogel Version 5.6 Copyri ...
- Git - Tutorial官方【转】
转自:http://www.vogella.com/tutorials/Git/article.html#git_rename_branch Lars Vogel Version 5.8 Copyri ...
- STL——迭代器与traits编程技法
一.迭代器 1. 迭代器设计思维——STL关键所在 在<Design Patterns>一书中对iterator模式定义如下:提供一种方法,使之能够依序巡访某个聚合物(容器)所含的各个元素 ...
- PHP面试题及答案解析(1)—PHP语法基础
1. strlen( )与 mb_strlen( )的作用分别是什么? strlen和mb_strlen都是用于获取字符串长度.strlen只针对单字节编码字符,也就是说它计算的是字符串的总字节数.如 ...
- STL源码剖析——iterators与trait编程#2 Traits编程技法
在算法中运用迭代器时,很可能用到其相应类型.什么是相应类型?迭代器所指对象的类型便是其中一个.我曾有一个错误的理解,那就是认为相应类型就是迭代器所指对象的类型,其实不然,相应类型是一个大的类别,迭代器 ...
随机推荐
- 实战分析一个运行起来会卡死的Go程序
序言 最近一位非常热心的网友建议结合demo来分析一下goroutine的调度器,而且还提供了一个demo代码,于是便有了本文,在此对这位网友表示衷心的感谢! 这位网友提供的demo程序可能有的gop ...
- 451. Sort Characters By Frequency (sort map)
Given a string, sort it in decreasing order based on the frequency of characters. Example 1: Input: ...
- iOS集成支付宝支付
本文由本人原创发表于博客园,转载请注明出处 http://www.cnblogs.com/wangqw/p/5074907.html 一. 开发前准备 iOS 支付宝SDK下载地址:(内含iOS An ...
- endless(2018.10.25)
这题就是个线段树合并板子. #include<cstdio> #include<algorithm> #include<cstring> using namespa ...
- 用css固定textarea文本域大小尺寸
textarea元素在chrome等浏览器下可以被拖拉从而改变大小,对于查看textarea里面的内容来说相当方便,但是有时候 我们为了保持网页的美观,不得不想要禁掉这个功能,禁止用户随意拉动text ...
- mysql状态查询
在监控中,都是去探测这些状态数据,然后换算到时间刻度上,像zabbix. show status like 'uptime'; --查看select语句的执行数 show [global] statu ...
- TCP常用方法
//格式化为16进制输出指令 function fromateSendCode($code){ $codeArr = getCodeWithSpace($code); for($i=0; $i< ...
- 如何使用fastJson来解析JSON格式数据和生成JSON格式数据
由于项目用到了JSON格式的数据,在网上搜索到了阿里的fastjson比较好用,特此记录fastjson用法,以备以后查询之用. decode: 首先创建一个JSON解析类: public class ...
- VMware下OSSIM 5.2.0的下载、安装和初步使用(图文详解)
不多说,直接上干货! 入门阶段不建议选用最新的版本. 采用OSSIM 4.11 到 OSSIM5.0.3 之间任何版本做实验,sensor的状态都会是“V”. 建议,入门,采用OSSIM5.0.0 ...
- centos设置ssh免密码登陆
准备工作: 1.确认本机sshd的配置文件(需要root权限) $ gedit /etc/ssh/sshd_config 找到以下内容,并去掉注释符”#“ RSAAuthentication y ...