WPF GroupBox Header Text Issue

BrianKE picture BrianKE · Aug 19, 2014 · Viewed 10.4k times · Source

I have the following XAML which displays correctly:

    <GroupBox Name="RulesGroupBox" Header="Rules">

        <StackPanel Name="RulesStackPanel"
                HorizontalAlignment="Left">

....

        </StackPanel>
    </GroupBox>

I now want to make the header text bold using the following (which I know works in other projects):

    <GroupBox Name="RulesGroupBox">
        <GroupBox.Header>
            <TextBlock FontWeight="Bold" Text="Rules"></TextBlock>
        </GroupBox.Header>

        <StackPanel Name="RulesStackPanel"
                HorizontalAlignment="Left">
....

        </StackPanel>
    </GroupBox>

For some reason, in this project, this change has the effect of making the text displayed for the Header text "System.Windows.Controls.TextBlock" and not "Rules". The text is now bold but not displaying "Rules".

Any idea why the chagne would not show "Rules" in bold?

Answer

Athari picture Athari · Aug 19, 2014

You likely have changed GroupBox's HeaderTemplate and this template supports displaying only text.