Skip to content

Commit 404d516

Browse files
Fixes darkmode issue in ComboBoxRenderer.
1 parent 8e53e03 commit 404d516

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/System.Windows.Forms/System/Windows/Forms/Control.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ public unsafe partial class Control :
163163
internal const string ItemsViewThemeIdentifier = "ItemsView";
164164
internal const string ComboBoxButtonThemeIdentifier = "CFD";
165165
internal const string BannerContainerThemeIdentifier = "FileExplorerBannerContainer";
166+
internal const string ComboboxClassIdentifier = "COMBOBOX";
166167

167168
private const short PaintLayerBackground = 1;
168169
private const short PaintLayerForeground = 2;

src/System.Windows.Forms/System/Windows/Forms/Controls/ComboBox/ComboBoxRenderer.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,15 @@ public static class ComboBoxRenderer
1414
// Make this per-thread, so that different threads can safely use these methods.
1515
[ThreadStatic]
1616
private static VisualStyleRenderer? t_visualStyleRenderer;
17-
private static readonly VisualStyleElement s_comboBoxElement = VisualStyleElement.ComboBox.DropDownButton.Normal;
17+
18+
#pragma warning disable WFO5001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
19+
20+
private static readonly VisualStyleElement s_comboBoxElement = Application.IsDarkModeEnabled
21+
? VisualStyleElement.CreateElement($"{Control.DarkModeIdentifier}_{Control.ComboBoxButtonThemeIdentifier}::{Control.ComboboxClassIdentifier}", 1, 1)
22+
: VisualStyleElement.ComboBox.DropDownButton.Normal;
23+
24+
#pragma warning restore WFO5001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
25+
1826
private static readonly VisualStyleElement s_textBoxElement = VisualStyleElement.TextBox.TextEdit.Normal;
1927

2028
/// <summary>

0 commit comments

Comments
 (0)