wpfthemedesigner-401016-export-a-custom-palette.md
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.
Click the Export ribbon button on the Palette tab to export your palette as a class ( .cs file ).
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"));
}
}
}
'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.
Imports System.Windows.Media
Imports DevExpress.Xpf.Core
Namespace CustomApp
Public Class App
Private Shared Sub New()
Dim palette = New DevExpressThemePalette()
Dim theme = Theme.CreateTheme(palette, Theme.Office2016ColorfulSE)
Theme.RegisterTheme(theme)
ApplicationThemeHelper.ApplicationThemeName = theme.Name
End Sub
End Class
Public Class DevExpressThemePalette
Inherits ThemePalette
Public Sub New()
MyBase.New("DevExpressPalette")
SetColor("Backstage.Button.Background", CType(ColorConverter.ConvertFromString("#FFFF7200"), Color))
SetColor("Backstage.Delimiter", CType(ColorConverter.ConvertFromString("#FFA53F22"), Color))
SetColor("Backstage.Editor.Background", CType(ColorConverter.ConvertFromString("#FFFF7200"), Color))
SetColor("Backstage.HoverBackground", CType(ColorConverter.ConvertFromString("#FFDA532C"), Color))
SetColor("Backstage.SelectionBackground", CType(ColorConverter.ConvertFromString("#FFF99D84"), Color))
SetColor("Backstage.Window.Background", CType(ColorConverter.ConvertFromString("#FFFF7200"), Color))
SetColor("Focused", CType(ColorConverter.ConvertFromString("#FFA53F22"), Color))
SetColor("Window.HeaderButton.HoverBackground", CType(ColorConverter.ConvertFromString("#FFDA532C"), Color))
SetColor("Window.HeaderButton.SelectionBackground", CType(ColorConverter.ConvertFromString("#FFF99D84"), Color))
End Sub
End Class
End Namespace
Note
The Theme Designer exports the palette as a .cs file and saves it in the Your_Theme_Folder.td\Publish folder.
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.
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;
}
}
Imports DevExpress.Xpf.Core
...
Public Partial Class App
Inherits Application
Private Shared Sub New()
Dim palette = New CustomApp.DevExpressThemePalette()
Dim theme = Theme.CreateTheme(palette, Theme.Office2016ColorfulSE)
Theme.RegisterTheme(theme)
ApplicationThemeHelper.ApplicationThemeName = theme.Name
End Sub
End Class
Tip
Refer to the Palettes topic for more information on how to display available palettes in the Ribbon gallery.
See Also