Over a million developers have joined DZone.

Detecting theme background in Windows Phone 7 applications

· Mobile Zone

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;
}
}

 

Topics:

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

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

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

{{ parent.tldr }}

{{ parent.urlSource.name }}