In many cases I have "small" styles that I want to apply but still "benefit" from globally set styles.
A small example:
<Windows.Resources>
<!-- a "small" style that only modifies a very small detail -->
<Style x:Key="S1" TargetType="Button">
<Setter Property="Background" Value="Yellow"/>
</Style>
<!-- the style I want to use in addition-->
<Style TargetType="Button">
<Setter Property="Foreground" Value="Blue"/>
</Style>
</Windows.Resources>
<!-- this Button should have a yellow background and a blue foreground -->
<Button Style="{StaticResource ResourceKey=S1}">S1</Button>
If I want to apply two styles, I have a solution based on this SO answer, but it's not applicable here since one style is implicit.
I also cannot make a style based on the other style, since style S1
doesn't know about the automatic style and the automatic style should apply to other controls too that don't use S1
.