Detecting the Windows Phone 7 Theme in c#

The Windows Phone 7 comes with two background color modes dark or light. Along with this ,there are ten accent colors that can be selected from .

The colors that you select here will show up in different places of the phone like the Tiles pinned in the Start Screen , Application List etc..

The easiest way to identify the Theme and the accent color that the user has choosen in the device can be found via the Application Resources that is used .

In the Development Environment , you can find the file ThemeResources.xaml in the path
C:\Program Files\Microsoft SDKs\Windows Phone\v7.0\Design

The background color of the Windows Phone 7 can be determined by

Color backgroundColor = (Color)Application.Current.Resources["PhoneBackgroundColor"];

The other Way to find if the Dark or Light Background is visible is again by using the Resources string PhoneLightThemeVisibility or PhoneDarkThemeVisibility which will give you information if visible or collapsed .

Visibility v = (Visibility)Resources["PhoneLightThemeVisibility"];
MessageBox.Show(v.ToString());
Visibility w = (Visibility)Resources["PhoneDarkThemeVisibility"];
MessageBox.Show(w.ToString());

The Accent Color can be accent colors can be determined with any of the following ways

SolidColorBrush x = (SolidColorBrush)Resources["PhoneAccentBrush"];
MessageBox.Show(x.Color.ToString());
Color accentColor = (Color)Application.Current.Resources["PhoneAccentColor"];
MessageBox.Show(accentColor.ToString());

You can find more information about Theme Resources in the MSDNResources for Windows Phone

 

If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

2 Comments

  1. Aliza Fathy January 8, 2011 Reply
  2. Detecting the Windows Phone 7 Theme in c | ProgramInDotnet August 1, 2011 Reply
  3. Karim January 19, 2012 Reply

Leave a Reply


x

Interesting BlogPosts to read

Download - Pokemon Go for for Windows 10 (Third Party app)
Pokemon Go is one of the popular AR games for android and iOS devices and now , the game is made ava...
Open Wordpad from command line in Windows
You can use the command "Write" from command line in Windows to open the WordPad application.D:\>...
Popular cross-platform (android and iOS) to-do list app
In this blog post, we will cover some of the popular to-do list app that is available on different p...