Skip to content

Commit d17c36a

Browse files
authored
Adds style for GroupBox in fluent (#10504)
* Adding style for GroupBox in fluent and also adding corresponding control and fluent brushes for the same * Makes padding a StaticResource * Addressing PR comments * Addressing PR comments 2.0 * Adds reference for GroupBox.xaml in Fluent.xaml * Updated value of BorderThickness * Makes DynamicResource binding of GroupBoxHeaderForeground * Replacing Foreground with TextElement.Foreground in ContentPresenter * Removing extra brush from HC.xaml
1 parent 575fdc7 commit d17c36a

File tree

8 files changed

+165
-0
lines changed

8 files changed

+165
-0
lines changed

src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Fluent/Resources/Theme/Dark.xaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@
259259
<SolidColorBrush x:Key="SystemFillColorSolidAttentionBackgroundBrush" Color="{StaticResource SystemFillColorSolidAttentionBackground}" />
260260
<SolidColorBrush x:Key="SystemFillColorSolidNeutralBackgroundBrush" Color="{StaticResource SystemFillColorSolidNeutralBackground}" />
261261

262+
262263
<!-- Elevation border brushes -->
263264

264265
<LinearGradientBrush x:Key="ControlElevationBorderBrush" MappingMode="Absolute" StartPoint="0,0" EndPoint="0,3">
@@ -482,6 +483,11 @@
482483
<SolidColorBrush x:Key="GridsplitterBackgroundDisabled" Color="{StaticResource ControlAltFillColorDisabled}" />
483484
<SolidColorBrush x:Key="GridsplitterForeground" Color="{StaticResource ControlStrongFillColorDefault}" />
484485

486+
<!-- GroupBox -->
487+
<SolidColorBrush x:Key="GroupBoxBackground" Color="Transparent" />
488+
<SolidColorBrush x:Key="GroupBoxBorderBrush" Color="Transparent" />
489+
<SolidColorBrush x:Key="GroupBoxHeaderForeground" Color="{StaticResource TextFillColorPrimary}" />
490+
485491
<!-- Hyperlink -->
486492
<SolidColorBrush x:Key="HyperlinkForeground" Color="{StaticResource SystemAccentColorLight3}" />
487493
<SolidColorBrush x:Key="HyperlinkForegroundPointerOver" Color="{StaticResource SystemAccentColorLight3}" />

src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Fluent/Resources/Theme/HC.xaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,11 @@
357357
<SolidColorBrush x:Key="GridsplitterBackgroundDisabled" Color="{StaticResource SystemColorWindowColor}" />
358358
<SolidColorBrush x:Key="GridsplitterForeground" Color="{StaticResource SystemColorButtonTextColor}" />
359359

360+
<!-- GroupBox -->
361+
<SolidColorBrush x:Key="GroupBoxBackground" Color="{StaticResource SystemColorButtonFaceColor}" />
362+
<SolidColorBrush x:Key="GroupBoxBorderBrush" Color="{StaticResource SystemColorButtonTextColor}" />
363+
<SolidColorBrush x:Key="GroupBoxHeaderForeground" Color="{StaticResource SystemColorButtonTextColor}" />
364+
360365
<!-- Hyperlink -->
361366
<SolidColorBrush x:Key="HyperlinkForeground" Color="{StaticResource SystemColorHotlightColor}" />
362367
<SolidColorBrush x:Key="HyperlinkForegroundPointerOver" Color="{StaticResource SystemColorHotlightColor}" />

src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Fluent/Resources/Theme/Light.xaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@
259259
<SolidColorBrush x:Key="SystemFillColorSolidAttentionBackgroundBrush" Color="{StaticResource SystemFillColorSolidAttentionBackground}" />
260260
<SolidColorBrush x:Key="SystemFillColorSolidNeutralBackgroundBrush" Color="{StaticResource SystemFillColorSolidNeutralBackground}" />
261261

262+
262263
<!-- Elevation border brushes -->
263264

264265
<LinearGradientBrush x:Key="ControlElevationBorderBrush" MappingMode="RelativeToBoundingBox" StartPoint="0,1" EndPoint="0,0">
@@ -478,6 +479,11 @@
478479
<SolidColorBrush x:Key="GridsplitterBackgroundPressed" Color="{StaticResource ControlAltFillColorQuarternary}" />
479480
<SolidColorBrush x:Key="GridsplitterBackgroundDisabled" Color="{StaticResource ControlAltFillColorDisabled}" />
480481
<SolidColorBrush x:Key="GridsplitterForeground" Color="{StaticResource ControlStrongFillColorDefault}" />
482+
483+
<!-- GroupBox -->
484+
<SolidColorBrush x:Key="GroupBoxBackground" Color="Transparent" />
485+
<SolidColorBrush x:Key="GroupBoxBorderBrush" Color="Transparent" />
486+
<SolidColorBrush x:Key="GroupBoxHeaderForeground" Color="{StaticResource TextFillColorPrimary}" />
481487

482488
<!-- Hyperlink -->
483489
<SolidColorBrush x:Key="HyperlinkForeground" Color="{StaticResource SystemAccentColorDark2}" />
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<ResourceDictionary
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:system="clr-namespace:System;assembly=System.Runtime">
5+
6+
<Thickness x:Key="GroupBoxPadding">0,0,0,16</Thickness>
7+
<system:Double x:Key="GroupBoxHeaderFontSize">20</system:Double>
8+
<Thickness x:Key="GroupBoxHeaderMargin">0,4,0,12</Thickness>
9+
<Thickness x:Key="GroupBoxBorderThickness">0</Thickness>
10+
11+
<Style x:Key="DefaultGroupBoxStyle" TargetType="{x:Type GroupBox}">
12+
<Setter Property="OverridesDefaultStyle" Value="True" />
13+
<Setter Property="BorderThickness" Value="{DynamicResource GroupBoxBorderThickness}" />
14+
<Setter Property="Background" Value="{DynamicResource GroupBoxBackground}" />
15+
<Setter Property="BorderBrush" Value="{DynamicResource GroupBoxBorderBrush}" />
16+
<Setter Property="Padding" Value="{DynamicResource GroupBoxPadding}" />
17+
<Setter Property="Template">
18+
<Setter.Value>
19+
<ControlTemplate TargetType="{x:Type GroupBox}">
20+
<Border
21+
BorderBrush="{TemplateBinding BorderBrush}"
22+
BorderThickness="{TemplateBinding BorderThickness}"
23+
Background="{TemplateBinding Background}"
24+
SnapsToDevicePixels="True">
25+
<Grid>
26+
<Grid.RowDefinitions>
27+
<RowDefinition Height="Auto" />
28+
<RowDefinition Height="*" />
29+
</Grid.RowDefinitions>
30+
<ContentPresenter
31+
Grid.Row="0"
32+
TextElement.FontSize="{DynamicResource GroupBoxHeaderFontSize}"
33+
Margin="{DynamicResource GroupBoxHeaderMargin}"
34+
ContentSource="Header"
35+
TextElement.Foreground="{DynamicResource GroupBoxHeaderForeground}"
36+
RecognizesAccessKey="True"
37+
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
38+
<ContentPresenter
39+
Grid.Row="1"
40+
Margin="{TemplateBinding Padding}"
41+
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
42+
</Grid>
43+
</Border>
44+
</ControlTemplate>
45+
</Setter.Value>
46+
</Setter>
47+
</Style>
48+
49+
<Style BasedOn="{StaticResource DefaultGroupBoxStyle}" TargetType="{x:Type GroupBox}" />
50+
51+
</ResourceDictionary>

src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Fluent/Themes/Fluent.Dark.xaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,10 @@
475475
<SolidColorBrush x:Key="GridsplitterBackgroundPressed" Color="{StaticResource ControlAltFillColorQuarternary}" />
476476
<SolidColorBrush x:Key="GridsplitterBackgroundDisabled" Color="{StaticResource ControlAltFillColorDisabled}" />
477477
<SolidColorBrush x:Key="GridsplitterForeground" Color="{StaticResource ControlStrongFillColorDefault}" />
478+
<!-- GroupBox -->
479+
<SolidColorBrush x:Key="GroupBoxBackground" Color="Transparent" />
480+
<SolidColorBrush x:Key="GroupBoxBorderBrush" Color="Transparent" />
481+
<SolidColorBrush x:Key="GroupBoxHeaderForeground" Color="{StaticResource TextFillColorPrimary}" />
478482
<!-- Hyperlink -->
479483
<SolidColorBrush x:Key="HyperlinkForeground" Color="{StaticResource SystemAccentColorLight3}" />
480484
<SolidColorBrush x:Key="HyperlinkForegroundPointerOver" Color="{StaticResource SystemAccentColorLight3}" />
@@ -2710,6 +2714,34 @@
27102714
</Setter>
27112715
</Style>
27122716
<Style BasedOn="{StaticResource DefaultGridSplitterStyle}" TargetType="{x:Type GridSplitter}" />
2717+
<Thickness x:Key="GroupBoxPadding">0,0,0,16</Thickness>
2718+
<system:Double x:Key="GroupBoxHeaderFontSize">20</system:Double>
2719+
<Thickness x:Key="GroupBoxHeaderMargin">0,4,0,12</Thickness>
2720+
<Thickness x:Key="GroupBoxBorderThickness">0</Thickness>
2721+
<Style x:Key="DefaultGroupBoxStyle" TargetType="{x:Type GroupBox}">
2722+
<Setter Property="OverridesDefaultStyle" Value="True" />
2723+
<Setter Property="BorderThickness" Value="{DynamicResource GroupBoxBorderThickness}" />
2724+
<Setter Property="Background" Value="{DynamicResource GroupBoxBackground}" />
2725+
<Setter Property="BorderBrush" Value="{DynamicResource GroupBoxBorderBrush}" />
2726+
<Setter Property="Padding" Value="{DynamicResource GroupBoxPadding}" />
2727+
<Setter Property="Template">
2728+
<Setter.Value>
2729+
<ControlTemplate TargetType="{x:Type GroupBox}">
2730+
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
2731+
<Grid>
2732+
<Grid.RowDefinitions>
2733+
<RowDefinition Height="Auto" />
2734+
<RowDefinition Height="*" />
2735+
</Grid.RowDefinitions>
2736+
<ContentPresenter Grid.Row="0" TextElement.FontSize="{DynamicResource GroupBoxHeaderFontSize}" Margin="{DynamicResource GroupBoxHeaderMargin}" ContentSource="Header" TextElement.Foreground="{DynamicResource GroupBoxHeaderForeground}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
2737+
<ContentPresenter Grid.Row="1" Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
2738+
</Grid>
2739+
</Border>
2740+
</ControlTemplate>
2741+
</Setter.Value>
2742+
</Setter>
2743+
</Style>
2744+
<Style BasedOn="{StaticResource DefaultGroupBoxStyle}" TargetType="{x:Type GroupBox}" />
27132745
<Style x:Key="{x:Type GroupItem}" TargetType="{x:Type GroupItem}">
27142746
<Setter Property="Template">
27152747
<Setter.Value>

src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Fluent/Themes/Fluent.HC.xaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,10 @@
373373
<SolidColorBrush x:Key="GridsplitterBackgroundPressed" Color="{StaticResource SystemColorHighlightColor}" />
374374
<SolidColorBrush x:Key="GridsplitterBackgroundDisabled" Color="{StaticResource SystemColorWindowColor}" />
375375
<SolidColorBrush x:Key="GridsplitterForeground" Color="{StaticResource SystemColorButtonTextColor}" />
376+
<!-- GroupBox -->
377+
<SolidColorBrush x:Key="GroupBoxBackground" Color="{StaticResource SystemColorButtonFaceColor}" />
378+
<SolidColorBrush x:Key="GroupBoxBorderBrush" Color="{StaticResource SystemColorButtonTextColor}" />
379+
<SolidColorBrush x:Key="GroupBoxHeaderForeground" Color="{StaticResource SystemColorButtonTextColor}" />
376380
<!-- Hyperlink -->
377381
<SolidColorBrush x:Key="HyperlinkForeground" Color="{StaticResource SystemColorHotlightColor}" />
378382
<SolidColorBrush x:Key="HyperlinkForegroundPointerOver" Color="{StaticResource SystemColorHotlightColor}" />
@@ -2691,6 +2695,34 @@
26912695
</Setter>
26922696
</Style>
26932697
<Style BasedOn="{StaticResource DefaultGridSplitterStyle}" TargetType="{x:Type GridSplitter}" />
2698+
<Thickness x:Key="GroupBoxPadding">0,0,0,16</Thickness>
2699+
<system:Double x:Key="GroupBoxHeaderFontSize">20</system:Double>
2700+
<Thickness x:Key="GroupBoxHeaderMargin">0,4,0,12</Thickness>
2701+
<Thickness x:Key="GroupBoxBorderThickness">0</Thickness>
2702+
<Style x:Key="DefaultGroupBoxStyle" TargetType="{x:Type GroupBox}">
2703+
<Setter Property="OverridesDefaultStyle" Value="True" />
2704+
<Setter Property="BorderThickness" Value="{DynamicResource GroupBoxBorderThickness}" />
2705+
<Setter Property="Background" Value="{DynamicResource GroupBoxBackground}" />
2706+
<Setter Property="BorderBrush" Value="{DynamicResource GroupBoxBorderBrush}" />
2707+
<Setter Property="Padding" Value="{DynamicResource GroupBoxPadding}" />
2708+
<Setter Property="Template">
2709+
<Setter.Value>
2710+
<ControlTemplate TargetType="{x:Type GroupBox}">
2711+
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
2712+
<Grid>
2713+
<Grid.RowDefinitions>
2714+
<RowDefinition Height="Auto" />
2715+
<RowDefinition Height="*" />
2716+
</Grid.RowDefinitions>
2717+
<ContentPresenter Grid.Row="0" TextElement.FontSize="{DynamicResource GroupBoxHeaderFontSize}" Margin="{DynamicResource GroupBoxHeaderMargin}" ContentSource="Header" TextElement.Foreground="{DynamicResource GroupBoxHeaderForeground}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
2718+
<ContentPresenter Grid.Row="1" Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
2719+
</Grid>
2720+
</Border>
2721+
</ControlTemplate>
2722+
</Setter.Value>
2723+
</Setter>
2724+
</Style>
2725+
<Style BasedOn="{StaticResource DefaultGroupBoxStyle}" TargetType="{x:Type GroupBox}" />
26942726
<Style x:Key="{x:Type GroupItem}" TargetType="{x:Type GroupItem}">
26952727
<Setter Property="Template">
26962728
<Setter.Value>

src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Fluent/Themes/Fluent.Light.xaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,10 @@
472472
<SolidColorBrush x:Key="GridsplitterBackgroundPressed" Color="{StaticResource ControlAltFillColorQuarternary}" />
473473
<SolidColorBrush x:Key="GridsplitterBackgroundDisabled" Color="{StaticResource ControlAltFillColorDisabled}" />
474474
<SolidColorBrush x:Key="GridsplitterForeground" Color="{StaticResource ControlStrongFillColorDefault}" />
475+
<!-- GroupBox -->
476+
<SolidColorBrush x:Key="GroupBoxBackground" Color="Transparent" />
477+
<SolidColorBrush x:Key="GroupBoxBorderBrush" Color="Transparent" />
478+
<SolidColorBrush x:Key="GroupBoxHeaderForeground" Color="{StaticResource TextFillColorPrimary}" />
475479
<!-- Hyperlink -->
476480
<SolidColorBrush x:Key="HyperlinkForeground" Color="{StaticResource SystemAccentColorDark2}" />
477481
<SolidColorBrush x:Key="HyperlinkForegroundPointerOver" Color="{StaticResource SystemAccentColorDark2}" />
@@ -2707,6 +2711,34 @@
27072711
</Setter>
27082712
</Style>
27092713
<Style BasedOn="{StaticResource DefaultGridSplitterStyle}" TargetType="{x:Type GridSplitter}" />
2714+
<Thickness x:Key="GroupBoxPadding">0,0,0,16</Thickness>
2715+
<system:Double x:Key="GroupBoxHeaderFontSize">20</system:Double>
2716+
<Thickness x:Key="GroupBoxHeaderMargin">0,4,0,12</Thickness>
2717+
<Thickness x:Key="GroupBoxBorderThickness">0</Thickness>
2718+
<Style x:Key="DefaultGroupBoxStyle" TargetType="{x:Type GroupBox}">
2719+
<Setter Property="OverridesDefaultStyle" Value="True" />
2720+
<Setter Property="BorderThickness" Value="{DynamicResource GroupBoxBorderThickness}" />
2721+
<Setter Property="Background" Value="{DynamicResource GroupBoxBackground}" />
2722+
<Setter Property="BorderBrush" Value="{DynamicResource GroupBoxBorderBrush}" />
2723+
<Setter Property="Padding" Value="{DynamicResource GroupBoxPadding}" />
2724+
<Setter Property="Template">
2725+
<Setter.Value>
2726+
<ControlTemplate TargetType="{x:Type GroupBox}">
2727+
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
2728+
<Grid>
2729+
<Grid.RowDefinitions>
2730+
<RowDefinition Height="Auto" />
2731+
<RowDefinition Height="*" />
2732+
</Grid.RowDefinitions>
2733+
<ContentPresenter Grid.Row="0" TextElement.FontSize="{DynamicResource GroupBoxHeaderFontSize}" Margin="{DynamicResource GroupBoxHeaderMargin}" ContentSource="Header" TextElement.Foreground="{DynamicResource GroupBoxHeaderForeground}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
2734+
<ContentPresenter Grid.Row="1" Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
2735+
</Grid>
2736+
</Border>
2737+
</ControlTemplate>
2738+
</Setter.Value>
2739+
</Setter>
2740+
</Style>
2741+
<Style BasedOn="{StaticResource DefaultGroupBoxStyle}" TargetType="{x:Type GroupBox}" />
27102742
<Style x:Key="{x:Type GroupItem}" TargetType="{x:Type GroupItem}">
27112743
<Setter Property="Template">
27122744
<Setter.Value>

src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Fluent/Themes/Fluent.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<ResourceDictionary Source="pack://application:,,,/PresentationFramework.Fluent;component/Styles/Expander.xaml" />
2424
<ResourceDictionary Source="pack://application:,,,/PresentationFramework.Fluent;component/Styles/Frame.xaml" />
2525
<ResourceDictionary Source="pack://application:,,,/PresentationFramework.Fluent;component/Styles/GridSplitter.xaml" />
26+
<ResourceDictionary Source="pack://application:,,,/PresentationFramework.Fluent;component/Styles/GroupBox.xaml" />
2627
<ResourceDictionary Source="pack://application:,,,/PresentationFramework.Fluent;component/Styles/GroupItem.xaml" />
2728
<ResourceDictionary Source="pack://application:,,,/PresentationFramework.Fluent;component/Styles/HeaderedContentControl.xaml" />
2829
<ResourceDictionary Source="pack://application:,,,/PresentationFramework.Fluent;component/Styles/Hyperlink.xaml" />

0 commit comments

Comments
 (0)