【问题标题】:Mahapps metro themes not available as no app.xamlMahapps Metro 主题不可用,因为没有 app.xaml
【发布时间】:2019-04-02 02:13:07
【问题描述】:
我正在开发一个 Office 插件,并希望添加一个 WPF Mahapps Windows。
一切顺利,但我无法应用 Mahapps Windows 样式。
查看教程here 我看到我更新了App.xaml 以添加各种主题。因为它不是 WPF 项目,所以我没有 App.xaml。
应用样式最有效的方法是什么?
我可以直接在 Windows 级别进行吗?
还是我需要手动创建一个App.xaml?
【问题讨论】:
标签:
mahapps.metro
app.xaml
【解决方案1】:
您也可以将所有 MahApps.Metro 资源放在 Window 资源标签中,例如
<Controls:MetroWindow x:Class="StyledWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Controls="http://metro.mahapps.com/winfx/xaml/controls">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! -->
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml"/>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml"/>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml"/>
<!-- Accent and AppTheme setting -->
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml"/>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<Grid>
</Grid>
</Controls:MetroWindow>
希望有帮助!