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}"/> 



  • 相关阅读:
    八数码(BFS)
    食物链(并查集)
    最大异或对(Trie)
    解决espeak编译的一些问题
    AcWing 3779. 相等的和
    AcWing 3775. 数组补全(环图)
    AcWing 3728. 城市通电(最小生成树)
    AcWing 3727. 乘方相乘(进位制)
    tarjan
    LC刷题简要记录
  • 原文地址:https://www.cnblogs.com/ljdong7/p/12666957.html
Copyright © 2011-2022 走看看