11

我对 WPF 比较陌生,我正在尝试将 Windows Metro Dark 主题应用于我的整个应用程序。

我在 Apps.xaml 中使用了以下内容,我可以正确看到 Windows Metro Light 主题。

<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <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" />
            <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>
</Application.Resources>

现在我想将主题更改为黑暗。我知道我可以随时使用,

ThemeManager.ChangeTheme()

但我相信应该有一种方法可以通过对应用程序的所有窗口有效的 XAML 来做到这一点。

我的问题: 有人可以指出我如何在源代码中不使用 ThemeManager 的情况下做到这一点吗?

4

1 回答 1

21

尝试使用BaseDark而不是BaseLight. 尝试更改此行:

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

对此:

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

这对我有用。我的应用程序使用 MahApps BaseDark 和 BaseLight 口音的屏幕截图:

BaseDark 在此处输入图像描述 Ba​​seLight 在此处输入图像描述

于 2014-01-26T12:27:41.033 回答