将自定义主题应用于DevExpress 15.1 WPF应用程序时遇到问题。
我已经完成了步骤:
在我的MainWindow中添加InitializeComponent()
:
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);
结果是例外:
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
内部异常
{"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)
你知道我做错了什么吗?也许它在15.1中发生了变化?
答案 0 :(得分:0)
你非常接近。
我将以下代码添加到App.xaml.cs的OnStartup方法中:
var myTheme = new Theme("Dark", "DevExpress.Xpf.Themes.Dark")
{
AssemblyName = "DevExpress.Xpf.Themes.Dark.v15.1"
};
Theme.RegisterTheme(myTheme);
ThemeManager.ApplicationThemeName = myTheme.Name;