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

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.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}