wpf 更改 MahApps Metro 主题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15917657/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 08:32:34  来源:igfitidea点击:

Changing The MahApps Metro Theme

wpfvisual-c++themesmahapps.metro

提问by gbmhunter

I know that the MahApps metro theme comes with "themes" (colour sets), but I don't know how to change them from the default settings in my WPF application.

我知道 MahApps 地铁主题带有“主题”(颜色集),但我不知道如何从我的 WPF 应用程序中的默认设置更改它们。

I have followed the beginners tutorial at MahApps.Metro Documentation(including adding the resource libraries at the top of the page), but it makes no mention about changing the theme.

我遵循了MahApps.Metro 文档中的初学者教程(包括在页面顶部添加资源库),但没有提及更改主题。

The component/Styles/Colours.xaml file has the comment "from the cosmopolitan theme pack", which may be a helpful clue to someone better versed in WPF design than me.

component/Styles/Colours.xaml 文件有“来自国际化主题包”的注释,这对于比我更精通 WPF 设计的人来说可能是一个有用的线索。

I'm talking about an app-wide theme change, not an individual control.

我说的是应用程序范围的主题更改,而不是单个控件。

回答by Rich

If you want to change the default colour scheme, just change which colour resource file is loaded.

如果要更改默认配色方案,只需更改加载的颜色资源文件即可。

from Blue:

来自蓝色:

    <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml" />

to Red:

到红色:

    <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Red.xaml" />

You can also change programatically (once you've loaded every colour resource file) using ThemeManager.ChangeTheme().

您还可以使用 ThemeManager.ChangeTheme() 以编程方式更改(一旦您加载了每个颜色资源文件)。