13

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?

Rohit Vats
  • 79,502
  • 12
  • 161
  • 185
Chathuranga Chandrasekara
  • 20,548
  • 30
  • 97
  • 138

1 Answers1

22

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 enter image description here BaseLight enter image description here

har07
  • 88,338
  • 12
  • 84
  • 137
  • Great.Thank you very much. This was the one I was thinking of? But one more question. How do I get the available list of Accents? :-) – Chathuranga Chandrasekara Jan 26 '14 at 13:26
  • well, I suspect accents is part that hasn't been documented yet (can't find documentation about it anywhere). But you can get accent list by peeking the source [here](https://github.com/MahApps/MahApps.Metro/tree/master/MahApps.Metro/Styles/Accents) – har07 Jan 26 '14 at 13:31
  • And one interesting observation. I create a new window from the parent window. new childWindow().show(). The theme has been applied but I can see that the title bar is not in Metro style. All the controllers are in Metro. I am investigating this. Any clue? – Chathuranga Chandrasekara Jan 26 '14 at 13:34
  • 1
    Found the mistake. A silly one. I've forgotten to add Controls:MetroWindow tag. Accepting the answer. – Chathuranga Chandrasekara Jan 26 '14 at 13:52