zoukankan      html  css  js  c++  java
  • Binding几种绑定方式

    绑定到DataContext:

    <Button Content=“{Binding DataTime}”/>

    绑定到DataContext,并设置绑定模式:

    <Button x:Name="btn" Content="{Binding DataTime,Mode = OneTime}"/>

    绑定到DataContext,并设置转换模式:

    <Button Content="{Binding DataTime,Converter={StaticResource ConvertResource},ConverterParmeter=btn"/>

    绑定到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}"/> 



  • 相关阅读:
    P3368 【模板】树状数组 2
    P3374 【模板】树状数组 1
    BZOJ 2654
    BZOJ 1016
    BZOJ 4870
    BZOJ 4868
    BZOJ 1503
    P3379 【模板】最近公共祖先(LCA)
    雅礼2017国庆1-1
    使用 CefSharp 网页显示问题
  • 原文地址:https://www.cnblogs.com/ljdong7/p/12666957.html
Copyright © 2011-2022 走看看