Skip to content

Commit 0628a77

Browse files
Made the following changes: (#9322)
1. Changed the KeyboardFocusBorderColor, CalendarViewItemBackgroundPointerOver and CalendarViewSelectedBackground values in High Contrast themes 2. Changed the ListBoxItemSelectedForegroundThemeBrush in the Light and Dark themes 3. Added explicit focus visual style to Button, ComboBox and DataGridCell 4. Updated the focus visual style of Expander 5. Added a Foreground property to ListBoxItem on Selected State
1 parent a1fc788 commit 0628a77

File tree

11 files changed

+71
-22
lines changed

11 files changed

+71
-22
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@
491491
<SolidColorBrush x:Key="ListBoxItemSelectedBackgroundThemeBrush" Color="{DynamicResource SystemAccentColor}" Opacity="0.6" />
492492
<SolidColorBrush x:Key="ListBoxItemSelectedBackgroundPointerOverThemeBrush" Color="{DynamicResource SystemAccentColor}" Opacity="0.8" />
493493
<SolidColorBrush x:Key="ListBoxItemBackgroundSelectedPressedThemeBrush" Color="{DynamicResource SystemAccentColor}" Opacity="0.9" />
494-
<!-- <SolidColorBrush x:Key="ListBoxItemSelectedForegroundThemeBrush" Color="{StaticResource TextOnAccentFillColorSecondary}" /> -->
494+
<SolidColorBrush x:Key="ListBoxItemSelectedForegroundThemeBrush" Color="{StaticResource TextFillColorPrimary}" />
495495
<SolidColorBrush x:Key="ListBoxItemUnselectedBackgroundPointerOverThemeBrush" Color="{StaticResource ControlAltFillColorTertiary}" />
496496

497497
<!-- ListView -->

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
<!-- Same as SystemColorWindowColor -->
3737
<SolidColorBrush x:Key="ApplicationBackgroundBrush" Color="{StaticResource ApplicationBackgroundColor}" />
3838

39-
<Color x:Key="KeyboardFocusBorderColor">#3D3D3D</Color>
39+
<Color x:Key="KeyboardFocusBorderColor">#FFFFFF</Color>
4040
<!-- Same as SystemColorWindowTextColor -->
4141
<SolidColorBrush x:Key="KeyboardFocusBorderColorBrush" Color="{StaticResource KeyboardFocusBorderColor}" />
4242

@@ -242,8 +242,8 @@
242242
<SolidColorBrush x:Key="CalendarViewForeground" Color="{StaticResource SystemColorButtonTextColor}" />
243243
<SolidColorBrush x:Key="CalendarViewBackground" Color="{StaticResource SystemColorWindowColor}" />
244244
<SolidColorBrush x:Key="CalendarViewBorderBrush" Color="{StaticResource SystemColorWindowTextColor}" />
245-
<SolidColorBrush x:Key="CalendarViewItemBackgroundPointerOver" Color="{StaticResource SystemColorWindowColor}" />
246-
<SolidColorBrush x:Key="CalendarViewSelectedBackground" Color="{StaticResource SystemColorWindowColor}" />
245+
<SolidColorBrush x:Key="CalendarViewItemBackgroundPointerOver" Color="{StaticResource SystemColorHighlightColor}" />
246+
<SolidColorBrush x:Key="CalendarViewSelectedBackground" Color="{StaticResource SystemColorHighlightColor}" />
247247
<SolidColorBrush x:Key="CalendarViewSelectedBorderBrush" Color="{StaticResource SystemColorHighlightColor}" />
248248
<SolidColorBrush x:Key="CalendarViewTodayBackground" Color="{StaticResource SystemColorHighlightColor}" />
249249
<SolidColorBrush x:Key="CalendarViewTodayForeground" Color="{StaticResource SystemColorHighlightTextColor}" />

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
<!-- Same as SystemColorWindowColor -->
3636
<SolidColorBrush x:Key="ApplicationBackgroundBrush" Color="{StaticResource ApplicationBackgroundColor}" />
3737

38-
<Color x:Key="KeyboardFocusBorderColor">#3D3D3D</Color>
38+
<Color x:Key="KeyboardFocusBorderColor">#FFFFFF</Color>
3939
<!-- Same as SystemColorWindowTextColor -->
4040
<SolidColorBrush x:Key="KeyboardFocusBorderColorBrush" Color="{StaticResource KeyboardFocusBorderColor}" />
4141

@@ -241,8 +241,8 @@
241241
<SolidColorBrush x:Key="CalendarViewForeground" Color="{StaticResource SystemColorButtonTextColor}" />
242242
<SolidColorBrush x:Key="CalendarViewBackground" Color="{StaticResource SystemColorWindowColor}" />
243243
<SolidColorBrush x:Key="CalendarViewBorderBrush" Color="{StaticResource SystemColorWindowTextColor}" />
244-
<SolidColorBrush x:Key="CalendarViewItemBackgroundPointerOver" Color="{StaticResource SystemColorWindowColor}" />
245-
<SolidColorBrush x:Key="CalendarViewSelectedBackground" Color="{StaticResource SystemColorWindowColor}" />
244+
<SolidColorBrush x:Key="CalendarViewItemBackgroundPointerOver" Color="{StaticResource SystemColorHighlightColor}" />
245+
<SolidColorBrush x:Key="CalendarViewSelectedBackground" Color="{StaticResource SystemColorHighlightColor}" />
246246
<SolidColorBrush x:Key="CalendarViewSelectedBorderBrush" Color="{StaticResource SystemColorHighlightColor}" />
247247
<SolidColorBrush x:Key="CalendarViewTodayBackground" Color="{StaticResource SystemColorHighlightColor}" />
248248
<SolidColorBrush x:Key="CalendarViewTodayForeground" Color="{StaticResource SystemColorHighlightTextColor}" />

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
<!-- Same as SystemColorWindowColor -->
3636
<SolidColorBrush x:Key="ApplicationBackgroundBrush" Color="{StaticResource ApplicationBackgroundColor}" />
3737

38-
<Color x:Key="KeyboardFocusBorderColor">#3D3D3D</Color>
38+
<Color x:Key="KeyboardFocusBorderColor">#FFFFFF</Color>
3939
<!-- Same as SystemColorWindowTextColor -->
4040
<SolidColorBrush x:Key="KeyboardFocusBorderColorBrush" Color="{StaticResource KeyboardFocusBorderColor}" />
4141

@@ -241,8 +241,8 @@
241241
<SolidColorBrush x:Key="CalendarViewForeground" Color="{StaticResource SystemColorButtonTextColor}" />
242242
<SolidColorBrush x:Key="CalendarViewBackground" Color="{StaticResource SystemColorWindowColor}" />
243243
<SolidColorBrush x:Key="CalendarViewBorderBrush" Color="{StaticResource SystemColorWindowTextColor}" />
244-
<SolidColorBrush x:Key="CalendarViewItemBackgroundPointerOver" Color="{StaticResource SystemColorWindowColor}" />
245-
<SolidColorBrush x:Key="CalendarViewSelectedBackground" Color="{StaticResource SystemColorWindowColor}" />
244+
<SolidColorBrush x:Key="CalendarViewItemBackgroundPointerOver" Color="{StaticResource SystemColorHighlightColor}" />
245+
<SolidColorBrush x:Key="CalendarViewSelectedBackground" Color="{StaticResource SystemColorHighlightColor}" />
246246
<SolidColorBrush x:Key="CalendarViewSelectedBorderBrush" Color="{StaticResource SystemColorHighlightColor}" />
247247
<SolidColorBrush x:Key="CalendarViewTodayBackground" Color="{StaticResource SystemColorHighlightColor}" />
248248
<SolidColorBrush x:Key="CalendarViewTodayForeground" Color="{StaticResource SystemColorHighlightTextColor}" />

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@
241241
<SolidColorBrush x:Key="CalendarViewForeground" Color="{StaticResource SystemColorButtonTextColor}" />
242242
<SolidColorBrush x:Key="CalendarViewBackground" Color="{StaticResource SystemColorWindowColor}" />
243243
<SolidColorBrush x:Key="CalendarViewBorderBrush" Color="{StaticResource SystemColorWindowTextColor}" />
244-
<SolidColorBrush x:Key="CalendarViewItemBackgroundPointerOver" Color="{StaticResource SystemColorWindowColor}" />
245-
<SolidColorBrush x:Key="CalendarViewSelectedBackground" Color="{StaticResource SystemColorWindowColor}" />
244+
<SolidColorBrush x:Key="CalendarViewItemBackgroundPointerOver" Color="{StaticResource SystemColorHighlightColor}" />
245+
<SolidColorBrush x:Key="CalendarViewSelectedBackground" Color="{StaticResource SystemColorHighlightColor}" />
246246
<SolidColorBrush x:Key="CalendarViewSelectedBorderBrush" Color="{StaticResource SystemColorHighlightColor}" />
247247
<SolidColorBrush x:Key="CalendarViewTodayBackground" Color="{StaticResource SystemColorHighlightColor}" />
248248
<SolidColorBrush x:Key="CalendarViewTodayForeground" Color="{StaticResource SystemColorHighlightTextColor}" />

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@
486486
<SolidColorBrush x:Key="ListBoxItemSelectedBackgroundThemeBrush" Color="{DynamicResource SystemAccentColor}" Opacity="0.4" />
487487
<SolidColorBrush x:Key="ListBoxItemSelectedBackgroundPointerOverThemeBrush" Color="{DynamicResource SystemAccentColor}" Opacity="0.6" />
488488
<SolidColorBrush x:Key="ListBoxItemBackgroundSelectedPressedThemeBrush" Color="{DynamicResource SystemAccentColor}" Opacity="0.7" />
489-
<SolidColorBrush x:Key="ListBoxItemSelectedForegroundThemeBrush" Color="{StaticResource TextOnAccentFillColorPrimary}" />
489+
<SolidColorBrush x:Key="ListBoxItemSelectedForegroundThemeBrush" Color="{StaticResource TextFillColorPrimary}" />
490490
<SolidColorBrush x:Key="ListBoxItemUnselectedBackgroundPointerOverThemeBrush" Color="{StaticResource ControlAltFillColorTertiary}" />
491491

492492
<!-- ListView -->

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

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,24 @@
1515
<Thickness x:Key="ButtonBorderThemeThickness">1</Thickness>
1616
<Thickness x:Key="ButtonIconMargin">0,0,8,0</Thickness>
1717

18+
<Style x:Key="ButtonFocusVisual">
19+
<Setter Property="Control.Template">
20+
<Setter.Value>
21+
<ControlTemplate>
22+
<Border>
23+
<Rectangle
24+
Margin="-3"
25+
StrokeThickness="1"
26+
Stroke="{DynamicResource KeyboardFocusBorderColorBrush}"
27+
SnapsToDevicePixels="true"/>
28+
</Border>
29+
</ControlTemplate>
30+
</Setter.Value>
31+
</Setter>
32+
</Style>
33+
1834
<Style x:Key="DefaultButtonStyle" TargetType="{x:Type ButtonBase}">
19-
<Setter Property="FocusVisualStyle" Value="{DynamicResource DefaultControlFocusVisualStyle}" />
35+
<Setter Property="FocusVisualStyle" Value="{DynamicResource ButtonFocusVisual}" />
2036
<Setter Property="Background" Value="{DynamicResource ButtonBackground}" />
2137
<Setter Property="Foreground" Value="{DynamicResource ButtonForeground}" />
2238
<Setter Property="BorderBrush" Value="{DynamicResource ControlElevationBorderBrush}" />
@@ -76,7 +92,7 @@
7692
</Style>
7793

7894
<Style x:Key="DefaultAccentButtonStyle" TargetType="{x:Type Button}">
79-
<Setter Property="FocusVisualStyle" Value="{DynamicResource DefaultControlFocusVisualStyle}" />
95+
<Setter Property="FocusVisualStyle" Value="{DynamicResource ButtonFocusVisual}" />
8096
<Setter Property="Background" Value="{DynamicResource AccentButtonBackground}" />
8197
<Setter Property="Foreground" Value="{DynamicResource AccentButtonForeground}" />
8298
<Setter Property="BorderBrush" Value="{DynamicResource AccentControlElevationBorderBrush}" />

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,22 @@
2424
<system:Double x:Key="ComboBoxPopupMinHeight">32.0</system:Double>
2525
<system:String x:Key="ComboBoxChevronDownGlyph">&#xE70D;</system:String>
2626

27+
<Style x:Key="ComboBoxFocusVisual">
28+
<Setter Property="Control.Template">
29+
<Setter.Value>
30+
<ControlTemplate>
31+
<Border>
32+
<Rectangle
33+
Margin="-3"
34+
StrokeThickness="1"
35+
Stroke="{DynamicResource KeyboardFocusBorderColorBrush}"
36+
SnapsToDevicePixels="true"/>
37+
</Border>
38+
</ControlTemplate>
39+
</Setter.Value>
40+
</Setter>
41+
</Style>
42+
2743
<Style x:Key="DefaultComboBoxTextBoxStyle" TargetType="{x:Type TextBox}">
2844
<!-- Focus by parent element -->
2945
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
@@ -145,7 +161,7 @@
145161

146162
<Style x:Key="DefaultComboBoxStyle" TargetType="{x:Type ComboBox}">
147163
<!-- Universal WPF UI focus -->
148-
<Setter Property="FocusVisualStyle" Value="{DynamicResource DefaultControlFocusVisualStyle}" />
164+
<Setter Property="FocusVisualStyle" Value="{DynamicResource ComboBoxFocusVisual}" />
149165
<!-- Universal WPF UI ContextMenu -->
150166
<Setter Property="ContextMenu" Value="{DynamicResource DefaultControlContextMenu}" />
151167
<Setter Property="Foreground" Value="{DynamicResource ComboBoxForeground}" />

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,30 @@
122122
</Setter>
123123
</Style>
124124

125+
<Style x:Key="DataGridCellFocusVisual">
126+
<Setter Property="Control.Template">
127+
<Setter.Value>
128+
<ControlTemplate>
129+
<Border>
130+
<Rectangle
131+
Margin="2"
132+
StrokeThickness="1"
133+
Stroke="{DynamicResource DataGridRowSelectedForegroundThemeBrush}"
134+
SnapsToDevicePixels="true"/>
135+
</Border>
136+
</ControlTemplate>
137+
</Setter.Value>
138+
</Setter>
139+
</Style>
140+
125141
<!-- Style and template for the DataGridCell. -->
126142
<Style x:Key="DefaultDataGridCellStyle" TargetType="{x:Type DataGridCell}">
127143
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
128144
<Setter Property="VerticalContentAlignment" Value="Stretch" />
129145
<Setter Property="MinHeight" Value="32" />
130146
<Setter Property="BorderThickness" Value="0" />
131147
<Setter Property="OverridesDefaultStyle" Value="True" />
148+
<Setter Property="FocusVisualStyle" Value="{StaticResource DataGridCellFocusVisual}"/>
132149
<Setter Property="Template">
133150
<Setter.Value>
134151
<ControlTemplate TargetType="{x:Type DataGridCell}">

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -269,11 +269,11 @@
269269
<Setter.Value>
270270
<ControlTemplate>
271271
<Border>
272-
<Rectangle Margin="0"
273-
StrokeThickness="1"
274-
Stroke="Black"
275-
StrokeDashArray="1 2"
276-
SnapsToDevicePixels="true"/>
272+
<Rectangle
273+
Margin="-3"
274+
StrokeThickness="1"
275+
Stroke="{DynamicResource KeyboardFocusBorderColorBrush}"
276+
SnapsToDevicePixels="true"/>
277277
</Border>
278278
</ControlTemplate>
279279
</Setter.Value>

0 commit comments

Comments
 (0)