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



  • 相关阅读:
    我还没死!!微信公众号——自媒体的营销之路
    网页中嵌入视频
    保存对象到文件中
    bash array
    正则表达式如何验证邮箱
    software testing
    Verification and validation
    bash array
    12 Linux Which Command, Whatis Command, Whereis Command Examples
    如何进行产品路标规划和项目排序?
  • 原文地址:https://www.cnblogs.com/ljdong7/p/12666957.html
Copyright © 2011-2022 走看看