Mahapps metro 主题不可用,因为没有 app.xaml

Mahapps metro themes not available as no app.xaml

我正在开发 Office 加载项 并想添加 WPF Mahapps Windows

一切顺利,但我无法应用 Mahapps Windows 样式。
查看教程 here 我发现我更新了 App.xaml 以添加各种主题。因为它不是 WPF 项目,所以我没有 App.xaml.

应用样式最有效的方法是什么?
可以直接在Windows级别做吗?
或者我需要手动创建一个 App.xaml?

您可以将所有 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>

希望对您有所帮助!