Checking Current Theme in WP7

If you would like to change the background of your WP7 app based on whether the user has selected the light or dark theme, you can determine if the user has selected the dark or light theme using code such as the following.  I use this in a shared WP7 helper library amongst all of my apps:

public static bool IsLightTheme()
        {
            Color LightThemeBackground = Color.FromArgb(255, 255, 255, 255);
            SolidColorBrush backgroundBrush = Application.Current.Resources["PhoneBackgroundBrush"] as SolidColorBrush;

            if (backgroundBrush.Color == LightThemeBackground)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
Advertisements

About Andrew Long

Web developer, Windows Phone developer: http://bit.ly/andrewlongWP, IBM Bluemix Evangelist: http://bit.ly/bluemixtrial
This entry was posted in WP7 and tagged . Bookmark the permalink.

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