Search code examples
wpfxamlheaderstylesgroupbox

XAML: How do I make part of a GroupBox Header bold?


I need to make the first part of a GroupBox Header bold, and the other part non-bold. Here is the goal I'm trying to achieve:

Students (Max: 32)

        <GroupBox Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="4" Margin="40, 80, 40, 80">
        <GroupBox.Header>
            <Span FontWeight="Bold">Students</Span>
            (Max: 32)
        </GroupBox.Header>
        <StackPanel>
        ...

This gives me the error: The property "Header" is set more than once.

I know that it works for TextBlocks, but I can't make it happen for GroupBox Headers:

        <TextBlock>
            <Span FontWeight="Bold">Students</Span>
            <Span>(Max: 32)</Span>
        </TextBlock>

Thanks.


Solution

  • <GroupBox.Header>
        <TextBlock>
            <Span FontWeight="Bold">Students</Span>
            <Span>(Max: 32)</Span>
        </TextBlock>
    </GroupBox.Header>