对于在样式下指定的模板中的边框:
<Thickness x:Key="CommonBorderThickness">2</Thickness>
<Style x:Key="CommonButtonStyle" TargetType="Button">
...
<Setter Property="BorderThickness" Value="2" />
...
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
...
<Border Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="0" Grid.RowSpan="2"
这很好用:
BorderThickness="{Binding Source={StaticResource CommonBorderThickness}, Converter={StaticResource FourGroupSizeConverter}}"
但这些不是:
BorderThickness="{TemplateBinding BorderThickness, Converter={StaticResource FourGroupSizeConverter}}"
BorderThickness="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness, Converter={StaticResource FourGroupSizeConverter}}"
关于为什么的任何想法?