DarkMode 1.1.3

dotnet add package DarkMode --version 1.1.3                
NuGet\Install-Package DarkMode -Version 1.1.3                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DarkMode" Version="1.1.3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DarkMode --version 1.1.3                
#r "nuget: DarkMode, 1.1.3"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install DarkMode as a Cake Addin
#addin nuget:?package=DarkMode&version=1.1.3

// Install DarkMode as a Cake Tool
#tool nuget:?package=DarkMode&version=1.1.3                

.NET DarkMode

Adds support for Windows 10 dark mode in .NET applications. Based on https://github.com/ysc3839/win32-darkmode.

Usage

Dark Mode can be enabled for your project in 2 easy steps:

Step 1: Enabling dark mode for your application

  1. Add a reference to the DarkMode.dll assembly in your application.
  2. Go to your project properties, and click View Application Events.
  3. 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

Step 2: Enabling dark mode for each window

  1. Open the class for one of your Forms.
  2. 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
  1. Repeat for every other Window you want to enable dark mode for.

Themes

This library supports three themes:

Theme Description
SYSTEM Respects the system dark mode setting.
DARK Forces dark mode.
LIGHT Forces light mode.

Other Methods

UpdateWindowTheme()

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.
Product Compatible and additional computed target framework versions.
.NET net5.0-windows7.0 is compatible.  net6.0-windows was computed.  net7.0-windows was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on DarkMode:

Package Downloads
DarkMode.Helper

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.3 352 12/24/2023
1.1.1 117 12/23/2023
1.1.0 122 12/22/2023
1.0.3 129 12/21/2023
1.0.2 670 4/25/2022
1.0.1 409 8/25/2021
1.0.0 354 8/25/2021