Adds support for Windows 10 dark mode in .NET applications. Based on https://github.com/ysc3839/win32-darkmode.
Dark Mode can be enabled for your project in 2 easy steps:
- Add a reference to the DarkMode.dll assembly in your application.
- Go to your project properties, and click View Application Events.
- Paste in the following code in the Application class:
- C#:
private void Application_Startup(Object sender, StartupEventArgs e) {
DarkMode.DarkMode.SetAppTheme(DarkMode.DarkMode.Theme.SYSTEM);
}
- Visual Basic:
Private Sub Application_Startup(sender As Object, e As StartupEventArgs) Handles MyBase.Startup
DarkMode.DarkMode.SetAppTheme(DarkMode.DarkMode.Theme.SYSTEM)
End Sub
- Open the class for one of your Forms.
- Add the following code:
- C#:
protected override void WndProc(ref Message m) {
DarkMode.WndProc(this, m, DarkMode.DarkMode.Theme.SYSTEM);
base.WndProc(m);
}
- Visual Basic:
Protected Overrides Sub WndProc(ByRef m As Message)
DarkMode.WndProc(Me, m, DarkMode.DarkMode.Theme.SYSTEM)
MyBase.WndProc(m)
End Sub
- Repeat for every other Window you want to enable dark mode for.
This library supports three themes:
Theme | Description |
---|---|
SYSTEM |
Respects the system dark mode setting. |
DARK |
Forces dark mode. |
LIGHT |
Forces light mode. |
Updates the theme for the specified window.
Signature:
- C#:
public void UpdateWindowTheme(Form window, Theme theme)
- Visual Basic:
Public Sub UpdateWindowTheme(window As Form, theme As Theme)
Parameters:
window
: The window to update the theme for.theme
: The new theme.