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

This blog post will guide you through several effective methods to troubleshoot and resolve the issue of Microsoft Edge not...
Windows 11 offers a range of audio enhancements that can enrich your listening experience. These enhancements include features like virtual...
Windows 11 brings a fresh and visually stunning design to your desktop, and one of the standout features is the...