Reputation: 2061
I have trouble with applying custom theme to DevExpress 15.1 WPF application.
I have done steps:
Add this before InitializeComponent()
in my MainWindow:
Theme theme = new Theme("MyTheme", "DevExpress.Xpf.Themes.MyTheme.v15.1");
theme.AssemblyName = "DevExpress.Xpf.Themes.MyTheme.v15.1";
Theme.RegisterTheme(theme);
ThemeManager.SetTheme(this, theme);
The result is exception:
An exception of type 'System.Reflection.TargetInvocationException' occurred in System.Xaml.dll but was not handled in user code
Additional information: Exception has been thrown by the target of an invocation
with inner exception
{"Object reference not set to an instance of an object."}
at DevExpress.Xpf.Core.ThemedElementsDictionary.GetAssemblyFullName(Object key)
at DevExpress.Xpf.Core.ThemedElementsDictionary.RegisterThemeType(String themeName, String fullName, Object key)
Do you have idea what I'm doing wrong? Maybe it has changed in 15.1?
Upvotes: 1
Views: 1143
Reputation: 11
You are pretty close.
I added the following code to the OnStartup method of the App.xaml.cs:
var myTheme = new Theme("Dark", "DevExpress.Xpf.Themes.Dark")
{
AssemblyName = "DevExpress.Xpf.Themes.Dark.v15.1"
};
Theme.RegisterTheme(myTheme);
ThemeManager.ApplicationThemeName = myTheme.Name;
Upvotes: 1