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编程技法
在算法中运用迭代器时,很可能用到其相应类型.什么是相应类型?迭代器所指对象的类型便是其中一个.我曾有一个错误的理解,那就是认为相应类型就是迭代器所指对象的类型,其实不然,相应类型是一个大的类别,迭代器 ...
随机推荐
- 658. Find K Closest Elements
Given a sorted array, two integers k and x, find the k closest elements to x in the array. The resul ...
- Unity(2) 脚本简单操作
生命周期(按顺序排列) Awake():脚本唤醒,系统执行的第一个方法,在脚本声明周期内只执行一次,初始化一般可以在这里 Start():Awake之后,Update之前,只执行一次,一般在awake ...
- [Xcode 实际操作]一、博主领进门-(15)读取当前应用的信息
目录:[Swift]Xcode实际操作 本文将演示读取当前应用的配置信息. 在项目导航区,打开视图控制器的代码文件[ViewController.swift] import UIKit class V ...
- 在指定的ChartArea中显示Series
WinForm的Chart有Series, ChartArea,输出图表就往Serie里扔数据就可以了,很方便是吧.我原想Area和serie有上下级关系,可是我错了,Area和Serie并没有上下级 ...
- iOS开发 - 多线程实现方案之NSOperation篇
NSOperation简介 1.实现多线程编程步骤: 配合使用NSOperation和NSOperationQueue实现多线程编程,我们不用考虑线程的生命周期.同步.加锁等问题,如下: 先将需要执行 ...
- self.tabBarController.selectedIndex
KindViewController *vc =((UINavigationController *) [self.tabBarController viewControllers][]).viewC ...
- celery (分布式系统)
celery 介绍 Celery - 分布式任务队列. Celery 是一个简单.灵活且可靠的,处理大量消息的分布式系统,并且提供维护这样一个系统的必需工具. 它是一个专注于实时处理的任务队列,同 ...
- Tinghua Data Mining 6
Networks 多层感知机 不是说这个神经网络要与人的大脑神经完全相似,也不是说要多么的强大,而是在一定程度上模拟了人脑神经元的能力,就足够了 为什么要w0呢,因为没有w0超平面一定会经过原点,所以 ...
- Mass Change Queries Codeforces - 911G
https://codeforces.com/contest/911/problem/G 没想到线段树合并还能这么搞.. 对每个权值建一个线段树(动态开点),如果权值为k的线段树上第i位为1,那么表示 ...
- 利用串口的硬件buf收发数据
很多单片机的串口可以设置硬件接收和发送的buf,这样可以减少中断的次数和cpu的浪费,方法就是:发送时根据串口波特率(通讯格式N-8-1)和硬件buf缓冲的字节数计算定时器的间隔(小于1000*buf ...