I'm trying to create a GroupBox design like this.
I have looked at the GroupBox.HeaderTemplate
but I'm having problems creating the blue background color, with a width of 100%. The same goes for the border.
My code so far
<GroupBox.HeaderTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Label Content="{Binding}" HorizontalAlignment="Stretch" Background="#25A0DA" Grid.Column="0" Height="20" Padding="5,0,0,0" Margin="1" Foreground="White"/>
</Grid>
</DataTemplate>
</GroupBox.HeaderTemplate>
And this is what it looks like right now.
Try this :
I realize this is way late, but the MahApps.Metro package has a nice GroupBox that seems to like nearly exactly like what is posted in the OP.
https://github.com/MahApps/MahApps.Metro/blob/develop/MahApps.Metro/Styles/Controls.GroupBox.xaml
Here's the Xaml from version 1.22
This thread is a bit old, but someone could find this useful...
A small modification to Jakob's answer if you want to have full width header.
You can bind to the parent GroupBox, so you can use it without having a named GroupBox.
Take the default GroupBox Template and alter it to look the way you want
For example,
You probably will not be able to make it look exactly like your example without writing a completely different template but I gave it a simple shot by binding the width of the grid in your HeaderTemplate to the width of the groupbox and by specifying appropriate margin and padding:
The result looks like this: