The requested page is not available for the requested platform. You are viewing the content for Default platform.
All docs
V19.2
19.2
19.1
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

Use a Palette in an Application

  • 3 min to read

This topic describes how to export a palette from the Theme Designer and use it in your application. Palettes allow you to change an application's colors without a Theme Designer theme assembly.

Export a Palette from the Theme Designer

Click the Export ribbon button on the Palette tab to export your palette as a class (.cs file).

Export Palette Ribbon Button

Show the exported .cs file content example

// The code sample below describes how to use the palette in an application. Refer to the Palettes topic (https://docs.devexpress.com/WPF/400728) for more information on how to use the palette in an application.

// ATTENTION! Add the DevExress.Xpf.Core.v*.dll and Mono.Cecil.dll references to the application.

using System.Windows.Media;
using DevExpress.Xpf.Core;

namespace CustomApp {
    public class App {
        static App() {
            var palette = new DevExpressThemePalette();
            var theme = Theme.CreateTheme(palette, Theme.Office2016ColorfulSE);
            Theme.RegisterTheme(theme);
            ApplicationThemeHelper.ApplicationThemeName = theme.Name;
        }
    }

    public class DevExpressThemePalette : ThemePalette {
        public NewTheme2ThemePalette() : base("DevExpressPalette") {
            SetColor("Backstage.Button.Background", (Color)ColorConverter.ConvertFromString("#FFFF7200"));
            SetColor("Backstage.Delimiter", (Color)ColorConverter.ConvertFromString("#FFA53F22"));
            SetColor("Backstage.Editor.Background", (Color)ColorConverter.ConvertFromString("#FFFF7200"));
            SetColor("Backstage.HoverBackground", (Color)ColorConverter.ConvertFromString("#FFDA532C"));
            SetColor("Backstage.SelectionBackground", (Color)ColorConverter.ConvertFromString("#FFF99D84"));
            SetColor("Backstage.Window.Background", (Color)ColorConverter.ConvertFromString("#FFFF7200"));
            SetColor("Focused", (Color)ColorConverter.ConvertFromString("#FFA53F22"));
            SetColor("Window.HeaderButton.HoverBackground", (Color)ColorConverter.ConvertFromString("#FFDA532C"));
            SetColor("Window.HeaderButton.SelectionBackground", (Color)ColorConverter.ConvertFromString("#FFF99D84"));
        }
    }
}
Note

The Theme Designer exports the palette as a .cs file and saves it in the Your_Theme_Folder\.td\Publish folder.

Apply the Palette to an Application

To use the .cs file exported from the Theme Designer, open your application, right-click the project, and select the Add Existing Item in the Add submenu. Select the generated .cs file.

Add the Palette Reference to Your Project

To apply the palette on the application startup, copy the static App() section from the .cs file to the App.xaml.cs:


using DevExpress.Xpf.Core;
    ...
public partial class App : Application
{
    static App()
    {
        var palette = new CustomApp.DevExpressThemePalette();
        var theme = Theme.CreateTheme(palette, Theme.Office2016ColorfulSE);
        Theme.RegisterTheme(theme);
        ApplicationThemeHelper.ApplicationThemeName = theme.Name;
    }
}
Tip

Refer to the Palettes topic for more information on how to display available palettes in the Ribbon gallery.

See Also