0
votes

I am aware that there are only 3 standard themes available on Windows Store 8.1 app. I'm OK with that. But I would like to change a single color or brush from the selected theme (for example I want to change ButtonBackgroundThemeBrush in the Light theme to solid Red) for my application. Anyone know how to achieve that?

I found these questions on SO:

Make own windows 8 app theme

How do I mix Light and Dark themes in a C#/XAML Windows Store (Metro UI) App?

Create a theme in Windows 8.1

but I could not find any clear answer.

2

2 Answers

1
votes

If I were you, I would set these colours in App.cs, possibly in the constructor, or a loaded event.

(App.Current.Resources["ButtonBackgroundThemeBrush"] as SolidColorBrush).Color = Colors.Red;

As far as I am aware, if the user changes the theme whilst the app is open, then the theme will remain until the user restarts the app. That being said, you will also need to take into account the current theme. For example, you do not want to set the theme brush to Red if the user is on the Dark theme. You can detect the current theme using the method outlined here.

0
votes

Ok, I found the way, just insert into App.xaml the following code:

<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.ThemeDictionaries>
            <ResourceDictionary x:Key="Light">
                <SolidColorBrush x:Key="ButtonBackgroundThemeBrush" Color="Red" />
            </ResourceDictionary>
        </ResourceDictionary.ThemeDictionaries>
    </ResourceDictionary>
</Application.Resources>