WPF GroupBox Header Text Release

I have the following XAML displaying correctly:

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

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

....

        </StackPanel>
    </GroupBox>

      

Now I want to make the title 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 causes the text to appear for the title text "System.Windows.Controls.TextBlock" rather than "Rules". The text is now in bold, but does not display Rules.

Any idea why chagne won't display "Rules" in bold?

+3


source to share


2 answers


You probably changed GroupBox

HeaderTemplate

and this template only supports displaying text.



+3


source


Header

defined more than once.

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

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

    </StackPanel>
</GroupBox>

      



"Rules" are in bold with this correction.

Edit: This answer was asked for a question prior to editing it. This is clearly not a good answer to the edited question.

+1


source







All Articles