整理:WPF中Binding的几种写法
目的:整理WPF中Bind的写法
-
<!--绑定到DataContext-->
-
<Button Content="{Binding DataTime}"/>
-
-
<!--绑定到DataContext,并设置绑定模式-->
-
<Button x:Name="btn" Content="{Binding DataTime,Mode=OneTime}"/>
-
-
<!--绑定到DataContext,并设置更新模式-->
-
<Button Content="{Binding DataTime,UpdateSourceTrigger=PropertyChanged}"/>
-
-
<!--绑定到DataContext,并设置转换模式-->
-
<Button Content="{Binding DataTime,Converter={StaticResource ConvertResource},ConverterParameter=btn1}"/>
-
-
<!--绑定到Element中指定属性-->
-
<Button Content="{Binding ElementName=btn,Path=Content}"/>
-
-
<!--绑定到相对位置中的自身模式-->
-
<Button Content="{Binding RelativeSource={RelativeSource Mode=Self},Path=Tag}" Tag="MyTag"/>
-
-
<!--绑定到相对位置中的父级别查找模式-->
-
<Button Content="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=Window},Path=Content}"/>
-
-
<!--绑定到相对位置中的父级别查找模式 绑定到指定类型-->
-
<Button Content="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=Window},Path=Content}"/>
-
-
<!--绑定到相对位置中的父级别查找模式 绑定到指定层级-->
-
<Button Content="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorLevel=2},Path=Content}"/>
-
-
<!--绑定到相对位置中的父级别查找模式 绑定到模板内容-->
-
<Button Content="{Binding RelativeSource={RelativeSource Mode=TemplatedParent},Path=Content}"/>
整理:WPF中Binding的几种写法的更多相关文章
- [转]WPF中Binding的技巧
在WPF应用的开发过程中Binding是一个非常重要的部分. 在实际开发过程中Binding的不同种写法达到的效果相同但事实是存在很大区别的. 这里将实际中碰到过的问题做下汇总记录和理解. 1. so ...
- 【转】WPF中Binding的技巧(一)
WPF中Binding的技巧(一) 在WPF应用的开发过程中Binding是一个非常重要的部分. 在实际开发过程中Binding的不同种写法达到的效果相同但事实是存在很大区别的. 这里将实际中碰到 ...
- javascript中面向对象的5种写法
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- ThinkPHP中Widget的两种写法及调用
Widget扩展一般用于页面组件的扩展,在页面根据需要输出不同的内容,下面介绍一下ThinkPHP中Widget的两种写法及调用 写法一: ArticlWidget.class.php文件: clas ...
- WPF中Binding使用StringFormat格式化字符串方法
原文:WPF中Binding使用StringFormat格式化字符串方法 货币格式 <TextBlock Text="{Binding Price, StringFormat={}{0 ...
- wpf中防止界面卡死的写法
原文:wpf中防止界面卡死的写法 ); this.Dispatcher.BeginInvoke(new Action(() => { this.button1.Content = "计 ...
- WPF之Binding的三种简单写法
环境 类代码 public class Person:INotifyPropertyChanged { private string name; public string Name { get { ...
- JQuey中ready()的4种写法
在jQuery中,对于ready()方法,共有4种写法: (1)写法一: $(document).ready(functin(){ //代码部分 }) 分析:这种代码形式是最常见的,其中$(docum ...
- Angularjs中controller的三种写法
在Angular中,Directive.Service.Filter.Controller都是以工厂方法的方式给出,而工厂方法的参数名对应着该工厂方法依赖的Service.angularjs中cont ...
随机推荐
- cmake设定boost python3
在mac上操作的.python3是anaconda环境下装的,3.7.1. boost是用brew装的,1.71.0版本. 按照FindBoost.cmake官方写法的CMakeLists.txt: ...
- python中os与sys作用与区别
https://www.cnblogs.com/cloak/p/11237285.html OS模块 在自动化测试中,经常需要查找操作文件,比如说查找配置文件(从而读取配置文件的信息),查找测试报告( ...
- xadmin引入celery4.0执行异步任务与定时任务
一.安装 pip install celery pip install django-celery-beat pip install django-celery-results pip install ...
- 在K8S集群中使用busybox-dig镜像,来作DNS解析分析
以前,判断K8S里的DNS功能是否正常时,得想很多办法. 如果有了busybox-dig镜像,则作这事就简单多了. 如下命令,直接部署 kubectl run busybox -it --image= ...
- 写一个function,清除字符串前后的空格(兼容所有的浏览器)
function trim1(str){ return str.replace(/(^\s*)|(\s*$)/g,""); }
- 图的遍历 | 1034 map处理输入数据,连通块判断
这题写得比较痛苦.首先有点不在状态,其次题目比较难读懂. “Gang”成立的两个条件:①成员数大于两个 ②边权总和大于阈值K 首先,在录数据的时候通过map或者字符串哈希建立string到int的映 ...
- 【牛客练习赛53】A-超越学姐爱字符串
// 题目地址:https://ac.nowcoder.com/acm/contest/1114/A /* 找规律(碰运气) n:1 = 2 n:2 = 3 n:3 = 5 n:4 = 8 ... d ...
- 深度学习之ResNet网络
介绍 Resnet分类网络是当前应用最为广泛的CNN特征提取网络. 我们的一般印象当中,深度学习愈是深(复杂,参数多)愈是有着更强的表达能力.凭着这一基本准则CNN分类网络自Alexnet的7层发展到 ...
- sort排序与二分查找
#include<iostream> #include<vector> #include<algorithm> #include<string> usi ...
- [技术博客]阿里云签名机制字符串的C语言实现
[技术博客]阿里云签名机制字符串的C语言实现 问题描述见:阿里云签名机制 话不多说,上字符串函数转化函数代码 bool AlicloudRequest::sendV2Request() { if( q ...