Win10Palette(Boolean, Nullable<WindowsAppMode>, Boolean, Nullable<Color>) Constructor
Initializes a new instance of the Win10Palette class with specified settings.
Namespace: DevExpress.Xpf.Core
Assembly: DevExpress.Xpf.Core.v24.2.dll
NuGet Package: DevExpress.Wpf.Core
#Declaration
public Win10Palette(
bool listenAppModeChanges,
WindowsAppMode? appMode = null,
bool listenAccentColorChanges = true,
Color? accentColor = null
)
#Parameters
Name | Type | Description |
---|---|---|
listen |
Boolean | true to create and apply a new palette to Win10 themes when a user changes the Windows app mode; otherwise, false. |
#Optional Parameters
Name | Type | Default | Description |
---|---|---|---|
app |
Nullable<Windows |
null | null to get the Windows app mode; otherwise, the app mode. |
listen |
Boolean | True | true to create and apply a new palette to Win10 themes when a user changes the Windows accent color; otherwise, false. |
accent |
Nullable<Color> | null | null to get the Windows accent color; otherwise, the accent color. |
#Remarks
Pass a Win10Palette object as a parameter to any Theme.CreateTheme method to generate a theme with a Windows accent color.
If listenAccentColorChanges or listenAppModeChange constructor parameters are true
, the palette generates a new theme each time a user changes accent color or app mode Windows settings.
The Win10Palette works with Windows 10 and higher. If the palette cannot find a Windows accent color or an app mode, these parameters are set to #FF0078D7
and Light
, respectively.
Tip
You can use the Theme.
#Listen Windows Accent Color and App Mode Changes
The code sample below performs the following actions:
- Generates a new theme based on Win10Dark/Win10Light theme (depending on the Windows app mode).
- Applies the Windows accent color to the generated theme.
- Applies the generated theme on the application 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);
}
#Create a Theme With the Specified Accent Color
The following code sample generates a new theme (based on the Win10Light) with the ffffb900
accent color and applies the theme on application startup:
protected override void OnStartup(StartupEventArgs e)
{
var palette = new Win10Palette((Color)ColorConverter.ConvertFromString("#ffffb900"), false);
var theme = Theme.CreateTheme(palette, Theme.Win10Light);
Theme.RegisterTheme(theme);
ApplicationThemeHelper.ApplicationThemeName = theme.Name;
base.OnStartup(e);
}