Use a white theme in your Windows 8 application

 

Just a quick post for now. When building a Windows 8 application, you get a black background by default & your controls automatically are based on this black background. If your application has a light theme (white background) you’ll find it cumbersome to change all controls. Luckily there’s a light_generic.xaml file available, included in all the SDK samples on dev.windows which takes care of having all controls to match the white theme. For your convenience I’ve uploaded the file, which you can download here.

Simply drag this file in your solution explorer, and it will get added to your App.xaml as a Resource Dictionary. Now you only need to change the background of your page/usercontrol to white, and it will work! Or maybe not… When you’d try to run your application, you’ll get a weird “Unable to Activate” error because there’s a small error in the automatically generated code in App.xaml. Simply remove the “/” before the file name and you’ll find that your app will work now, and all of the controls will nicely match your white background.

<Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="light_generic.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s