Skip to main content

ThemePalette Class

A WPF Theme palette.

Namespace: DevExpress.Xpf.Core

Assembly: DevExpress.Xpf.Core.v24.2.dll

NuGet Package: DevExpress.Wpf.Core

Declaration

public class ThemePalette :
    ThemePaletteBase

Remarks

Create and Customize a Palette

Create a palette instance and use the SetColor method to set color values to palette colors. The code snippet below changes the SelectionBackground and Foreground palette colors:

var mypalette = new ThemePalette("CustomPalette");
mypalette.SetColor("SelectionBackground", Colors.Red);
mypalette.SetColor("Foreground", Colors.Black);

Create a Theme with the Palette

To apply a dynamic palette to an application, you should create a new theme. This theme should be based on a Theme with a Palette. Specify the base theme and the dynamic palette name and use the CreateTheme method to create a new theme assembly.

var customtheme = Theme.CreateTheme(mypalette, Theme.Office2016ColorfulSE);

Apply the Palette to an Application

Register the created theme and apply it to an application.

Theme.RegisterTheme(customtheme);
ApplicationThemeHelper.ApplicationThemeName = customtheme.Name;

Cache Palette Themes

You can cache the current palette theme’s assembly to reduce the theme loading time. The application uses the cached assemblies at the current and the following application runs.

Set the Theme.CachePaletteThemes to true to cache the current palette theme’s assembly. The following code sample enables the palette theme assemblies caching to a default directory and applies the Office2019Colorful theme with the RedWine predefined palette to the application:

Theme.CachePaletteThemes = true;
Theme.RegisterPredefinedPaletteThemes();
ApplicationThemeHelper.ApplicationThemeName = "RedWineOffice2019Colorful";

Specify the Cache Location

Use the Theme.PaletteThemeCacheDirectory property to specify the directory where the cached assemblies are stored. The default cache directory is %LocalAppData%\DevExpress\PaletteThemeCache. The following code sample changes the default cache directory:

Theme.PaletteThemeCacheDirectory = "C:\\DevExpress\\PaletteThemeCache";

Clear the Cache

To remove the directory with the cached assemblies, use the Theme.ClearPaletteThemeCache method:

Theme.ClearPaletteThemeCache();

Inheritance

See Also