Saturday, November 27, 2010

Determining theme on WP7

Knowing which theme has been selected by the user for their WP7 device is important especially if you are using images or colors that work well for one theme and not another. In this case you will have to change the colors/images depending on the currently selected theme.

Here is the simplest way to determine whether the currently selected theme is “Light” or “Dark”

public static bool LightThemeEnabled
return (Visibility)Application.Current.Resources["PhoneLightThemeVisibility"] == Visibility.Visible;

The property returns true if the currently selected theme is the light theme and false if the selected theme is the dark theme.

Incidentally, this is one of the easiest reasons for your app to get rejected during certification for the Market Place. So remember to check all your screens under both the Light and Dark themes.

No comments: