Win10Palette Class
A palette that can get the Windows accent color and app mode, and update the theme each time a user changes these Windows settings.
Namespace: DevExpress.Xpf.Core
Assembly: DevExpress.Xpf.Core.v24.1.dll
NuGet Package: DevExpress.Wpf.Core
Declaration
Remarks
Pass a Win10Palette object as a parameter to a Theme.CreateTheme method to generate a theme based on a Win10Dark or Win10Light DevExpress theme. The palette allows you to get the following Windows theme settings, listen to their changes, and apply them to your application:
- Accent color
- App mode (Dark/Light)
Refer to the following Microsoft help topic for more information: Change colors in Windows
The Win10Palette
works with Windows 10 and higher.
Manage Palette Settings
When creating a Win10Palette instance, you can use the following constructor parameters to manage palette settings:
- accentColor
- Specifies a palette accent color. If the palette cannot find a Windows accent color, the application accent color is set to
#FF0078D7
. - listenAccentColorChanges
Specifies whether to get or ignore Windows accent color changes.
If
true
, the Win10Palette performs the following actions when a user changes an accent color in Windows:- Gets a Windows accent color.
- Creates a theme with the accent color.
- Applies the theme to an application.
If
false
, the Win10Palette ignores Windows accent color changes.- appMode
- Specifies an app mode. If the palette cannot find a Windows app mode, the application app mode is set to
Light
. - listenAppModeChanges
Specifies whether to get or ignore Windows app mode changes.
If
true
, the Win10Palette performs the following actions when a user changes an accent color in Windows:- Gets a Windows app mode.
- Creates a theme that is based on a Dark/Light theme (depends on the selected Windows app mode).
- Applies the theme to an application.
If
false
, the Win10Palette ignores Windows app mode changes.
Tip
You can use the Theme.CachePaletteThemes property to cache the current palette theme assembly. The cache reduces load times in future application runs.
Example
The code sample below creates a theme with colors based on Windows settings and applies it to an application on startup:
protected override void OnStartup(StartupEventArgs e) {
var palette = new Win10Palette(true);
var theme = Theme.CreateTheme(palette);
Theme.RegisterTheme(theme);
ApplicationThemeHelper.ApplicationThemeName = theme.Name;
base.OnStartup(e);
}