相关疑难解决方法(0)

WPF TemplateBinding与RelativeSource TemplatedParent

这两个绑定有什么区别:

<ControlTemplate TargetType="{x:Type Button}">
   <Border BorderBrush="{TemplateBinding Property=Background}">
      <ContentPresenter />
   </Border>
</ControlTemplate>
Run Code Online (Sandbox Code Playgroud)

<ControlTemplate TargetType="{x:Type Button}">
   <Border BorderBrush="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Background}">
      <ContentPresenter />
   </Border>
</ControlTemplate>
Run Code Online (Sandbox Code Playgroud)

wpf relativesource templatebinding

164
推荐指数
4
解决办法
10万
查看次数

标签 统计

relativesource ×1

templatebinding ×1

wpf ×1