原文:整理: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. INS-35178错误,AMM及ASMM区别

    遇到这个报错,就使用asmm 一般先装库,再opatch到最新补丁,最后dbca建库,物理内存大于4G不能用AMM只能用ASMM 内存越大,全自动管理就越费劲,出错概率就越高,内存抖动 oracle的 ...

  2. Nginx配置文件 nginx.conf 和default.conf 讲解

    nginx.conf /etc/nginx/nginx.conf ######Nginx配置文件nginx.conf中文详解##### #定义Nginx运行的用户和用户组 user www www; ...

  3. centos7 安装 ffmpeg

    升级系统 yum install epel-release -yyum update -y 安装Nux Dextop Yum源 由于centos 没有官方软件包,我们可以使用第三方YUM源(Nux D ...

  4. Nginx 核心配置-作为上传服务器配置

    Nginx 核心配置-作为上传服务器配置 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任.   一.关键参数说明 client_max_body_size 1m: 设置允许客户端上传单 ...

  5. php观察者模式(observer pattern)

    ... <?php /* The observer pattern implements a one-too-many dependency between objects. The objec ...

  6. MySQL 的各种 join

    table th:first-of-type { width: 200px; } join 类型 备注 left [outer] join right [outer] join union [all ...

  7. MySQL体系结构与存储引擎

    MySQL 体系结构 先看 MySQL 数据库的体系结构,如下图所示. MySQL 体系结构由 Client Connectors 层.MySQL Server 层及存储引擎层组成. Client C ...

  8. 完美解决该死的ie6下select总是置于最上层bug

    <html> <head> <meta http-equiv="Content-Type" content="text/html; char ...

  9. 排序算法-插入排序(Java)

    package com.rao.linkList; import java.util.Arrays; /** * @author Srao * @className InsertSort * @dat ...

  10. Django ORM性能优化 和 图片验证码

    一,ORM性能相关 1. 关联外键, 只拿一次数据 all_users = models.User.objects.all().values('name', 'age', 'role__name') ...