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"];
Visibility w = (Visibility)Resources["PhoneDarkThemeVisibility"];

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

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

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