mengjiulong

Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorLevel=1, AncestorType={x:Type Grid}}, Path=Name}"

数据绑定之RelativeSource

       <TextBlockWidth="{Binding RelativeSource={RelativeSource Self}, Path=Parent.ActualWidth}"/>

        这其中的RelativeSource是指定了Width属性绑定的是Self.Parent.ActualWidth(TextBlock父窗口的实际大小),表示该TextBlock的宽度与父窗口的宽度一致。

           RelativeSource有四种Mode,包括FindAncestor,Self,TemplateParent,PriviousData.

RelativeSource的具体解释是: 指定与当前控件相对位置的控件作为数据绑定的源。

分类:

技术点:

相关文章:

  • 2021-09-24
  • 2019-03-24
  • 2018-07-19
  • 2021-11-07
  • 2021-09-24
  • 2021-09-24
  • 2021-08-10
  • 2021-09-13
猜你喜欢
  • 2021-09-24
  • 2021-09-24
  • 2021-09-24
  • 2021-09-24
  • 2021-09-24
  • 2021-09-24
  • 2021-09-24
相关资源
相似解决方案