I am setting a global style on a TextBlock, like so:
<FontFamily x:Key="DefaultFontFamily">Consolas</FontFamily>
<SolidColorBrush x:Key="DefaultFontColour" Color="#96EED5"/>
<Style TargetType="TextBlock">
<Setter Property="FontFamily" Value="{DynamicResource DefaultFontFamily}"/>
<Setter Property="Foreground" Value="{DynamicResource DefaultFontColour}"/>
</Style>
And I am setting a global style for a GroupBox, like so:
<Style TargetType="GroupBox">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="GroupBox">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Text="{TemplateBinding Header}"/>
<Rectangle Grid.Row="1" Height="1" Fill="{TemplateBinding Foreground}"/>
<ContentPresenter Grid.Row="2"
Margin="0,6,0,0"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Here's the problem, the TextBlock for the GroupBox's header does not pick up the global TextBlock style. Here's an example GroupBox being used in the application:
<GroupBox Header="SOME HEADER HERE">
<TextBlock TextWrapping="Wrap">
This is a very very very very
very very very very very very
very very very very very very
very very very very very very
long string.</TextBlock>
</GroupBox>
Shows the following groupbox:
Why isn't the GroupBox ControlTemplate picking up the global style for the TextBlock?
Thanks in advance.