Themes/MaterialDesignTheme.GroupBox.xaml

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:converters="clr-namespace:MaterialDesignThemes.Wpf.Converters"
                    xmlns:wpf="clr-namespace:MaterialDesignThemes.Wpf">
 
  <Style x:Key="MaterialDesignHeaderedContentControl" TargetType="{x:Type HeaderedContentControl}">
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type HeaderedContentControl}">
          <StackPanel>
            <wpf:ColorZone>
              <ContentPresenter ContentSource="Header" />
            </wpf:ColorZone>
            <ContentPresenter />
          </StackPanel>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>
 
 
  <Style x:Key="MaterialDesignGroupBox" TargetType="{x:Type GroupBox}">
    <Setter Property="Background" Value="Transparent" />
    <Setter Property="BorderThickness" Value="1" />
    <Setter Property="Foreground" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type FrameworkElement}}, Path=(TextElement.Foreground)}" />
    <Setter Property="Padding" Value="9" />
    <Setter Property="wpf:GroupBoxAssist.HeaderPadding" Value="9" />
    <Setter Property="SnapsToDevicePixels" Value="true" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type GroupBox}">
          <Grid x:Name="OuterGrid">
            <Border x:Name="Border"
                    Background="{TemplateBinding Background}"
                    BorderBrush="{Binding Path=Background, ElementName=PART_ColorZone}"
                    BorderThickness="{TemplateBinding BorderThickness}" />
            <DockPanel Margin="{TemplateBinding BorderThickness}">
              <wpf:ColorZone x:Name="PART_ColorZone"
                             Padding="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:GroupBoxAssist.HeaderPadding)}"
                             wpf:ColorZoneAssist.Background="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ColorZoneAssist.Background)}"
                             wpf:ColorZoneAssist.Foreground="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ColorZoneAssist.Foreground)}"
                             DockPanel.Dock="Top"
                             Mode="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ColorZoneAssist.Mode)}"
                             SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                             UseLayoutRounding="True">
                <ContentPresenter ContentSource="Header"
                                  ContentStringFormat="{TemplateBinding HeaderStringFormat}"
                                  ContentTemplate="{TemplateBinding HeaderTemplate}"
                                  ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}"
                                  RecognizesAccessKey="True"
                                  SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
              </wpf:ColorZone>
              <ContentPresenter Margin="{TemplateBinding Padding}"
                                ContentStringFormat="{TemplateBinding ContentStringFormat}"
                                ContentTemplate="{TemplateBinding ContentTemplate}"
                                ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
            </DockPanel>
          </Grid>
          <ControlTemplate.Triggers>
            <DataTrigger Binding="{Binding ElementName=Border, Path=Background, Converter={x:Static converters:IsTransparentBrushConverter.Instance}}" Value="True">
              <Setter TargetName="PART_ColorZone" Property="Effect" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ElevationAssist.Elevation), Converter={x:Static converters:ShadowConverter.Instance}}" />
            </DataTrigger>
            <DataTrigger Binding="{Binding ElementName=Border, Path=Background, Converter={x:Static converters:IsTransparentBrushConverter.Instance}}" Value="False">
              <Setter TargetName="OuterGrid" Property="Effect" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ElevationAssist.Elevation), Converter={x:Static converters:ShadowConverter.Instance}}" />
            </DataTrigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Setter Property="wpf:ColorZoneAssist.Mode" Value="PrimaryMid" />
    <Setter Property="wpf:ElevationAssist.Elevation" Value="Dp0" />
  </Style>
 
  <Style x:Key="MaterialDesignCardGroupBox" TargetType="{x:Type GroupBox}">
    <Setter Property="Background" Value="Transparent" />
    <Setter Property="BorderThickness" Value="0" />
    <Setter Property="Foreground" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type FrameworkElement}}, Path=(TextElement.Foreground)}" />
    <Setter Property="Padding" Value="9" />
    <Setter Property="wpf:GroupBoxAssist.HeaderPadding" Value="9" />
    <Setter Property="SnapsToDevicePixels" Value="true" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type GroupBox}">
          <wpf:Card VerticalAlignment="Stretch" wpf:ElevationAssist.Elevation="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ElevationAssist.Elevation)}">
            <DockPanel Background="{TemplateBinding Background}">
              <wpf:ColorZone x:Name="PART_ColorZone"
                             Padding="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:GroupBoxAssist.HeaderPadding)}"
                             wpf:ColorZoneAssist.Background="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ColorZoneAssist.Background)}"
                             wpf:ColorZoneAssist.Foreground="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ColorZoneAssist.Foreground)}"
                             DockPanel.Dock="Top"
                             Mode="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ColorZoneAssist.Mode)}">
                <ContentPresenter ContentSource="Header"
                                  ContentStringFormat="{TemplateBinding HeaderStringFormat}"
                                  ContentTemplate="{TemplateBinding HeaderTemplate}"
                                  ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}"
                                  RecognizesAccessKey="True"
                                  SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
              </wpf:ColorZone>
              <ContentPresenter Margin="{TemplateBinding Padding}"
                                ContentStringFormat="{TemplateBinding ContentStringFormat}"
                                ContentTemplate="{TemplateBinding ContentTemplate}"
                                ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
            </DockPanel>
          </wpf:Card>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Setter Property="wpf:ColorZoneAssist.Mode" Value="PrimaryMid" />
    <Setter Property="wpf:ElevationAssist.Elevation" Value="Dp1" />
  </Style>
</ResourceDictionary>