<!--第一种默认的方式 指定绑定的数据源和路径-->
        <TextBlock Text="{Binding Source={StaticResource ViewModel}, Path=temp}" ></TextBlock>
        <!--第二种采用Element方式-->
            <TextBlock Text="{Binding ElementName=mainwindow, Path=Title}"></TextBlock>
        <!--第三种采用相对源RelativeSource方式-->
        <TextBlock Text="{Binding RelativeSource={RelativeSource AncestorType=Window,Mode=FindAncestor},Path=Title }" Foreground="Orange"></TextBlock>
        <!--第4种采用父对象Datacontext进行数据源指定-->
        <TextBlock Text="{Binding Path=value}" DataContext="{StaticResource  ViewModel}"></TextBlock>

相关文章:

  • 2022-02-08
  • 2022-12-23
  • 2021-08-02
  • 2022-12-23
  • 2021-07-02
  • 2022-12-23
  • 2021-06-09
  • 2022-12-23
猜你喜欢
  • 2021-10-20
  • 2022-02-08
  • 2022-12-23
  • 2022-02-08
  • 2022-02-08
相关资源
相似解决方案