Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Detecting theme background in Windows Phone 7 applications

DZone's Guide to

Detecting theme background in Windows Phone 7 applications

· Mobile Zone
Free Resource

Download this comprehensive Mobile Testing Reference Guide to help prioritize which mobile devices and OSs to test against, brought to you in partnership with Sauce Labs.

As you have probably noticed Windows Phone 7 platform allows you to change the Background (Theme) in emulator and on real device. It can be accomplished in Settings -> Theme menu (check image bellow). As a developer I sometimes need to determine what background theme is currently applied to a phone to take advantage of it during the development.

 

Currently, you are able to pick one theme among “light” and “dark”. Notice that “dark” theme is considered as more battery-friendly theme. Now I am going to show two properties I use to detect both themes. Usually I use only one of them per project.

public bool  IsLightTheme
{
get
{
return (Visibility)Resources["PhoneLightThemeVisibility"]
== Visibility.Visible;
}
}

public bool IsDarkTheme
{
get
{
return (Visibility)Resources["PhoneDarkThemeVisibility"]
== Visibility.Visible;
}
}

 

Analysts agree that a mix of emulators/simulators and real devices are necessary to optimize your mobile app testing - learn more in this white paper, brought to you in partnership with Sauce Labs.

Topics:

Published at DZone with permission of Jevgeni Tšaikin. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}