我正在尝试这样做......
<Style
x:Key="MyBorderStyle"
TargetType="Border">
<Setter
Property="BorderBrush"
Value="{StaticResource MyBorderBrush}" />
<Setter
Property="Background"
Value="{StaticResource MyBackgroundBrush}" />
<Setter
Property="Padding"
Value="{TemplateBinding Padding}" />
</Style>
Run Code Online (Sandbox Code Playgroud)
...但我收到错误: 'Padding' member is not valid because it does not have a qualifying type name.
我如何提供"合格类型名称"?
注意:我试图这样做的原因是,我想在一系列类似的ControlTemplates中包含相同的Border.
谢谢.
编辑:
好吧,我试过这个......
<Setter
Property="Padding"
Value="{TemplateBinding GridViewColumnHeader.Padding}" />
Run Code Online (Sandbox Code Playgroud)
......它实际编译了,但是当我运行应用程序时,我得到了XamlParseException:
Cannot convert the value in attribute 'Value' to object of type ''.
我想,也许有资格Padding与GridViewColumnHeader(这是我想用这种风格与控件模板)的工作,但没有骰子.
编辑2:
那么,根据文档TemplateBinding,它说:
将控件模板中的属性值链接为模板化控件上某些其他公开属性的值.
所以听起来我正在尝试做的事情显然是不可能的.我真的希望能够为我的控件模板中的某些控件创建可重用的样式,但我想模板绑定不能包含在这些样式中.