-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
.NET version
9.0.100-rc.2.24430.10
Did it work in .NET Framework?
No
Did it work in any of the earlier releases of .NET Core or .NET 5+?
Dark mode is a new feature in net9
Issue description
Some toolstrip colors don't change when the SystemColorMode is changed while the app is running, even after re-creating the form. (It works fine when setting the SystemColorMode at app start.)
Correct (when starting the app in dark mode):
Incorrect (when starting the app in light mode, switching to dark mode, and re-creating the form):
I believe the root cause of the issue is here, where there is a static cache of brushes with an index based on the KnownColor
enum (e.g. KnownColor.ControlText
). I imagine the solution involves purging these caches when the color mode is changed.
public static Brush FromSystemColor(Color c) |
Also here has a similar problem, though I haven't evaluated if there are further impacts from these static caches.
public static Pen FromSystemColor(Color c) |
Steps to reproduce
- Start the application with
Application.SetColorMode(SystemColorMode.Classic)
- Call
Application.SetColorMode(SystemColorMode.Dark)
- Close and re-open a form with a toolbar
- Observe that ToolStripSeparator and dropdown arrows on ToolStripSplitButton have the wrong color