il santino
il santino

Reputation: 117

How to change the header background of a GroupBox?

How can I change the Background of the header of a GroupBox? I'm trying to do that with:

<GroupBox Grid.Row="0">
   <GroupBox.Header>
       <Setter Property="Background" //<- no backgroundproperty

there is no Background property

Upvotes: 3

Views: 9050

Answers (3)

Yvonnila
Yvonnila

Reputation: 646

You can define a Border in the Header and set the Background of it to your desired color:

<GroupBox >
    <GroupBox.Header>
        <Border Background="Red">
            <Label Content="Hello"></Label>
        </Border>
    </GroupBox.Header>
</GroupBox>

Upvotes: 4

oppassum
oppassum

Reputation: 1775

Take a look at this site: Control Templates, Styles, and Triggers

this is probably more than you need, but it explains how to use a control template to modify controls in various ways. I use this particular control (with different colors) for groupboxes on one of my applications, and it has come in very handy.

Upvotes: 0

mm8
mm8

Reputation: 169420

You could set the Header property to any UI element including a Grid or a Border for example:

<GroupBox>
    <GroupBox.Header>
        <Border Background="Green">
            <TextBlock Text="header..." />
        </Border>
    </GroupBox.Header>
    <TextBlock Text="content..."></TextBlock>
</GroupBox>

enter image description here

Upvotes: 3

Related Questions