dotnet / dotnet/winforms

[Dark Mode] Button with FlatStyle = Flat: FlatAppearance properties not working in Dark Mode

Open
#13,897 0 comments 2 reactions 1 assignee Claimed by @LeafShi1 View on GitHub
area-DarkMode
Dominant language
C#
Stars
4.9k
Forks
1.1k
Avg merge
20h 23m
Merged PRs (30d)
103

Description

### .NET version

.NET 10 with 10.0.100-rc.2.25468.104 build

### Did it work in .NET Framework?

Not tested/verified

### Did it work in any of the earlier releases of .NET Core or .NET 5+?

DarkMode is a new feature in .NET 10

### Issue description

When using a Button with `FlatStyle = Flat` in a WinForms application, setting properties under the `FlatAppearance` property (such as `BorderColor, BorderSize, MouseDownBackColor, MouseOverBackColor`, etc.) does not work or apply correctly under app's **Dark Mode**
Like this setting code:
```
button2.FlatAppearance.BorderColor = Color.Fuchsia;
button2.FlatAppearance.BorderSize = 5;
button2.FlatAppearance.CheckedBackColor = Color.Yellow;
button2.FlatAppearance.MouseDownBackColor = Color.FromArgb(255, 255, 128);
button2.FlatAppearance.MouseOverBackColor = Color.Blue;
button2.FlatStyle = FlatStyle.Flat;
```
**Dark Mode:** has a problem: `FlatAppearance` properties (like `BorderColor, BorderSize, MouseDownBackColor, MouseOverBackColor`) are ignored. The button renders with the default system style, and custom appearance settings are not visible.

https://github.com/user-attachments/assets/fc97d540-b26b-49c5-8a51-735d5c66f78d

**Classic Mode:** works well

https://github.com/user-attachments/assets/c789c178-d1c1-4566-8154-ce389ce237a2

### Steps to reproduce

1. Create a Winforms .NET 10 project
2. Add a button to the form
3. Set the button's `FlatStyle` to `Flat`, and set the properties `BorderColor, BorderSize, MouseDownBackColor, MouseOverBackColor` with custom values under FlatAppearance for button
4. Enable the DarkMode in program.cs
`Application.SetColorMode(SystemColorMode.Dark);`
5. Build and run app to observe button

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.