people in couch

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

Share:

    1 Comment

  1. Karim
    January 19, 2012
    Reply

    Hello, I am making an application but I want the color of the buttons is this white font for the black theme. I don’t want the bottoms to be changed when the user chooses the light theme. somehow I want to disconnect my application from the theme chosen, is there a way to do so ?
    Thanks.

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

In this post, you’ll learn about the Win32 Error “0x000019E5 – ERROR_COULD_NOT_RESIZE_LOG” that you get when debugging system erors in...
In this post, you’ll learn about the error “CO_E_DBERROR 0x8004E02B” that is returned when working with COM based APIs or...
In this post, you’ll learn about the Win32 Error “0x000019D0 – ERROR_LOG_BLOCK_VERSION” that you get when debugging system erors in...