简体   繁体   中英

Applying MahApps.Metro Dark theme

I am relatively new to WPF and I am trying to apply Windows Metro Dark theme to my entire application.

I used the following in my Apps.xaml and I can see the Windows Metro Light theme properly.

<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>

Now I want to change the theme to Dark. I understand I can always use,

ThemeManager.ChangeTheme()

But I believe there should be a way to do this with XAML effective to all the windows of the application.

My Question : Can someone point me how to do this without using ThemeManager in source code?

Try to use BaseDark instead of BaseLight . Try to change this line :

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

to this :

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

That did the trick for me. Screenshot of my application using MahApps BaseDark and BaseLight accents:

BaseDark 在此输入图像描述 BaseLight 在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM