1

我看过 mahapps.metro 的演示,我想允许使用按钮更改主题。

我有一个带有处理程序的按钮,当我单击该按钮时,它会给我一个NullReferenceException.

var theme = ThemeManager.DetectTheme(Application.Current)

主题返回空值。

我是这个领域的新手。请帮我。非常感谢!

4

1 回答 1

1

您可以按如下方式更改主题:

var accent = ThemeManager.DefaultAccents.First(x => x.Name == "Blue");

//dark theme
ThemeManager.ChangeTheme(Application.Current, Accent newAccent, Theme.Dark);

//light theme
ThemeManager.ChangeTheme(Application.Current, Accent newAccent, Theme.Light);

不要错过导入该部分中资源的 MahApp App.Resources

于 2013-12-04T13:40:28.143 回答