我将此样式定位为TextBlock
<Style TargetType="TextBlock" x:Key="TahomaBase">
<Setter Property="FontFamily" Value="Tahoma"/>
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="TextWrapping" Value="NoWrap"/>
</Style>
我是否可以将目标类型更改为textBox和Combobox的共同祖先,以便我将该样式用作两种组件类型的基础?
答案 0 :(得分:1)
试试这个。
<Style TargetType="TextBlock" x:Key="TahomaBase" BasedOn="{StaticResource YourStyleAncestor}">
<Setter Property="FontFamily" Value="Tahoma" />
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="TextWrapping" Value="NoWrap"/>
</Style>