4

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.

MrProgrammer
  • 589
  • 1
  • 7
  • 17

2 Answers2

10
<GroupBox.Header>
    <TextBlock>
        <Span FontWeight="Bold">Students</Span>
        <Span>(Max: 32)</Span>
    </TextBlock>
</GroupBox.Header>
  • 1
    Just to add a quick note that helped me a lot once, like Ed says it can contain just about whatever since at it's [template level](https://msdn.microsoft.com/en-us/library/ms744748(v=vs.110).aspx) it's a `ContentPresenter` so you can dump just about any CLR object in it and at template level you can add a lot of cool functionality to it with things like custom tooltips to interaction events, to whatever. Super handy in some instances. :) +1 – Chris W. Dec 21 '16 at 19:29
  • 1
    That sounded very easy with the explanation you've provided. Thank you very much. – MrProgrammer Dec 21 '16 at 20:09
1
 <GroupBox.Header>
                <TextBlock>
                    <Span FontWeight="Bold">Students</Span>
                    <Span>(Max: 32)</Span>
                    </TextBlock>
            </GroupBox.Header>
dman
  • 145
  • 13