原文:整理:WPF中Binding的几种写法

目的:整理WPF中Bind的写法


  1. <!--绑定到DataContext-->
  2. <Button Content="{Binding DataTime}"/>
  3. <!--绑定到DataContext,并设置绑定模式-->
  4. <Button x:Name="btn" Content="{Binding DataTime,Mode=OneTime}"/>
  5. <!--绑定到DataContext,并设置更新模式-->
  6. <Button Content="{Binding DataTime,UpdateSourceTrigger=PropertyChanged}"/>
  7. <!--绑定到DataContext,并设置转换模式-->
  8. <Button Content="{Binding DataTime,Converter={StaticResource ConvertResource},ConverterParameter=btn1}"/>
  9. <!--绑定到Element中指定属性-->
  10. <Button Content="{Binding ElementName=btn,Path=Content}"/>
  11. <!--绑定到相对位置中的自身模式-->
  12. <Button Content="{Binding RelativeSource={RelativeSource Mode=Self},Path=Tag}" Tag="MyTag"/>
  13. <!--绑定到相对位置中的父级别查找模式-->
  14. <Button Content="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=Window},Path=Content}"/>
  15. <!--绑定到相对位置中的父级别查找模式 绑定到指定类型-->
  16. <Button Content="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=Window},Path=Content}"/>
  17. <!--绑定到相对位置中的父级别查找模式 绑定到指定层级-->
  18. <Button Content="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorLevel=2},Path=Content}"/>
  19. <!--绑定到相对位置中的父级别查找模式 绑定到模板内容-->
  20. <Button Content="{Binding RelativeSource={RelativeSource Mode=TemplatedParent},Path=Content}"/>

整理:WPF中Binding的几种写法的更多相关文章

  1. [转]WPF中Binding的技巧

    在WPF应用的开发过程中Binding是一个非常重要的部分. 在实际开发过程中Binding的不同种写法达到的效果相同但事实是存在很大区别的. 这里将实际中碰到过的问题做下汇总记录和理解. 1. so ...

  2. 【转】WPF中Binding的技巧(一)

    WPF中Binding的技巧(一)   在WPF应用的开发过程中Binding是一个非常重要的部分. 在实际开发过程中Binding的不同种写法达到的效果相同但事实是存在很大区别的. 这里将实际中碰到 ...

  3. javascript中面向对象的5种写法

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  4. ThinkPHP中Widget的两种写法及调用

    Widget扩展一般用于页面组件的扩展,在页面根据需要输出不同的内容,下面介绍一下ThinkPHP中Widget的两种写法及调用 写法一: ArticlWidget.class.php文件: clas ...

  5. WPF中Binding使用StringFormat格式化字符串方法

    原文:WPF中Binding使用StringFormat格式化字符串方法 货币格式 <TextBlock Text="{Binding Price, StringFormat={}{0 ...

  6. wpf中防止界面卡死的写法

    原文:wpf中防止界面卡死的写法 ); this.Dispatcher.BeginInvoke(new Action(() => { this.button1.Content = "计 ...

  7. WPF之Binding的三种简单写法

    环境 类代码 public class Person:INotifyPropertyChanged { private string name; public string Name { get { ...

  8. JQuey中ready()的4种写法

    在jQuery中,对于ready()方法,共有4种写法: (1)写法一: $(document).ready(functin(){ //代码部分 }) 分析:这种代码形式是最常见的,其中$(docum ...

  9. Angularjs中controller的三种写法

    在Angular中,Directive.Service.Filter.Controller都是以工厂方法的方式给出,而工厂方法的参数名对应着该工厂方法依赖的Service.angularjs中cont ...

随机推荐

  1. UNITY Serializer 序列化 横向对比

    UNITY Serializer 序列化 横向对比 关于序列化,无论是.net还是unity自身都提供了一定保障.然而人总是吃着碗里想着锅里,跑去github挖个宝是常有的事.看看各家大佬的本事.最有 ...

  2. Python 实现两个矩形重合面积

    计算两个矩形的重合面积 import math x1, y1, x2, y2 = input().split(" ") x1, y1, x2, y2=int(x1), int(y1 ...

  3. 03、磁盘管理+swap分区创建+磁盘配额+自动挂载

    磁盘管理 分区标识 一般用4位标识,前两位,磁盘类型,第3位,磁盘编号,第4位,分区编号 如: /dev/sda1     sd  磁盘类型    a  磁盘编号   1  分区编号 [root@s1 ...

  4. Linux(Centos7)安装Oracle11.2.0数据字典初始化,监听,网络,创建用户等部分配置

    #创建数据字典和pl/sql包 @/u01/app/oracle/product/11.2.0/db_1/rdbms/admin/catalog.sql; @/u01/app/oracle/produ ...

  5. shell 脚本命令之alias

    1.alias的功能 设置一个别名,即为一个长命令起一个新的名字 2.alias的基本格式 alias   alias_name='origin_command' alias是指定别名命令的关键字 a ...

  6. Python实现十大经典排序算法(史上最简单)。

    十大排序算法(Python实现)一. 算法介绍及相关概念解读 算法分类十种常见排序算法可以分为两大类: 非线性时间比较类排序:通过比较来决定元素间的相对次序,由于其时间复杂度不能突破O(nlogn), ...

  7. arduino驱动步进电机

    https://learn.adafruit.com/adafruit-motor-shield-v2-for-arduino/install-software 1安装库 Adafruit_Motor ...

  8. Pandas | 28 与SQL比较

    由于许多潜在的Pandas用户对SQL有一定的了解,因此本文章旨在提供一些如何使用Pandas执行各种SQL操作的示例. 文件:tips.csv - total_bill,tip,sex,smoker ...

  9. Python全栈--目录导航

    这里更新以Python语言作为基础,想要成为全栈工程师需要掌握的技能... Python基础语法 day01 初识Python day02 while循环 运算符和编码 day03 字符串 day04 ...

  10. uname 命令简介

    [root@localhost root]# uname --help Usage: uname [OPTION]... Print certain system information. With ...