【发布时间】:2015-09-07 18:01:07
【问题描述】:
在 WPF 中,我有一个控件样式,如下所示,
<Style TargetType="local:CustomControl">
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="Gray" />
<Setter Property="BorderThickness" Value="0,0,0,1" />
<Setter Property="Padding" Value="3,0,3,0" />
<Setter Property="IsTabStop" Value="False" />
<Setter Property="VerticalContentAlignment" Value="Center" />
</Style>
现在我需要为下面的其他地方覆盖 customcontrol 边框,
<Style TargetType="local:CustomControl" BasedOn="{StaticResource {x:Type local:CustomControl}}">
<Setter Property="BorderThickness" Value="1" />
</Style>
我的问题是当我使用上面的代码时,它会覆盖第一次编写的代码。我的代码是否正确。
注意:基本样式只写目标类型。我需要在不影响基本代码的情况下在其他地方覆盖该控件边框。
有可能吗?请帮我解决这个问题。
提前致谢。
【问题讨论】:
标签: c# xaml styles wpf-controls