Fix Issue 14005: [DarkMode] the Pane in the Anchor Editor should adapt to the dark mode#14715
Fix Issue 14005: [DarkMode] the Pane in the Anchor Editor should adapt to the dark mode#14715SimonZhao888 wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Updates the AnchorEditor drop-down UI so the center placeholder renders appropriately under WinForms dark mode, avoiding the overly bright/white center block reported in #14005.
Changes:
- Set the center placeholder (
ControlPlaceholder) background toSystemColors.ControlDarkwhenApplication.IsDarkModeEnabled. - In dark mode, replace
ControlPaint.DrawButton(...)with explicit fill + border drawing; keep the existing button-style rendering for non-dark mode.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| public ControlPlaceholder() | ||
| { | ||
| BackColor = SystemColors.Control; | ||
| if (Application.IsDarkModeEnabled) |
There was a problem hiding this comment.
Minor: the dark-mode decision is duplicated here (for BackColor) and again in OnPaint. Since BackColor is captured only at construction while OnPaint re-evaluates Application.IsDarkModeEnabled on every paint, the two could diverge if the process color mode changes after this control is created. Consider centralizing the decision, or relying solely on OnPaint.
There was a problem hiding this comment.
ControlPaint.DrawButton(e.Graphics, rc, ButtonState.Normal); draws a button but does not fill it with color; therefore, we need to fill it when in dark mode.
|
|
||
| if (Application.IsDarkModeEnabled) | ||
| { | ||
| e.Graphics.FillRectangle(SystemBrushes.ControlDark, rc); |
There was a problem hiding this comment.
BackColor is already set to SystemColors.ControlDark in the constructor, so the default OnPaintBackground fills the client area with that same color before OnPaint runs. This explicit FillRectangle repaints the identical color and appears redundant — the dark branch really only needs the DrawRectangle border. Consider dropping the fill.
There was a problem hiding this comment.
In reality, it does not perform automatic filling; we still need to fill it in manually.
| if (Application.IsDarkModeEnabled) | ||
| { | ||
| e.Graphics.FillRectangle(SystemBrushes.ControlDark, rc); | ||
| e.Graphics.DrawRectangle(SystemPens.WindowFrame, rc.X, rc.Y, rc.Width - 1, rc.Height - 1); |
There was a problem hiding this comment.
In the dark palette SystemColors.WindowFrame is typically near-black, so a border drawn with it over a ControlDark fill against the surrounding dark container may have very low contrast. Could you confirm from the dark-mode screenshot that this border is actually visible? If it isn't, a lighter system color (e.g. SystemColors.ControlLight or ActiveBorder) would read better and stay consistent with the 3D button edge shown in light mode.
There was a problem hiding this comment.
Adding a border is not recommended, as borders are typically used to indicate states like selection or clicking, whereas a ControlPlaceholder cannot be selected.
Fixes #14005
Proposed changes
Updated the center placeholder (ControlPlaceholder) visual rendering in AnchorEditor.AnchorUI for dark mode.
Customer Impact
Regression?
Risk
Screenshots
Before
After
Dark Mode

Normal

Test methodology
Test environment(s)
Microsoft Reviewers: Open in CodeFlow