How to detect the dark or light theme in Windows Phone 7

If the user of the Windows Phone 7 device switches from the default dark theme to the light theme, how do you detect which one is in use? In the MSDN article Theme Resources for Windows Phone, there are two interesting resource keys that you can query. These are the PhoneDarkThemeVisibility and PhoneLightThemeVisibility keys. So based on these we can determine if we should use a dark or light background image in our application, like so:

Windows Phone 7 Theme Colors

The Windows Phone 7 has two different background color modes; dark or light. In addition, there are ten accent colors to choose from.

image image

There’s currently no simple way of detecting which theme and accent color that the user has selected his or her device. However, since the colors of the current theme is injected into to applications resources, one can at least read out the various colors from there.

The background color can be determined using this piece of code:

And in a similar fashion the foreground and accent colors can be determined like this:

All the various resource names are described here; Theme Resources for Windows Phone.

Theme Background Color Value Foreground Color Value
Dark #FF000000 #FFFFFFFF
Light #FFFFFFFF #DE000000
Accent color Value
01-WP7-magenta-accent
#FFFF0097
02-WP7-purple-accent #FFA200FF
03-WP7-teal-accent #FF00ABA9
04-WP7-lime-accent #FF8CBF26
05-WP7-brown-accent #FFA05000
06-WP7-pink-accent #FFE671B8
07-WP7-orange-accent #FFF09609
08-WP7-blue-accent #FF1BA1E2
09-WP7-red-accent #FFE51400
10-WP7-green-accent #FF339933

Upcoming books on Windows Phone 7 development

Reading a book about Windows Phone 7 development is a great way to get you started on developing on the Windows Phone 7. Here is a list of known upcoming books on the subject.

Beginning-Windows-Phone7-Development

Beginning Windows Phone 7 Development

by Henry Lee
Published by Apress.
More info

Pro-Windows-Phone7-Development

Pro Windows Phone 7 Development

by Rob Cameron
Published by Apress
More info

Windows-Phone7-Game-Development

 

Windows Phone 7 Game Development
by Adam Dawes
Published by Apress
More info

WindowsPhone7Unleashed[7]

Windows Phone 7 Unleashed

by Daniel Vaughan

Published by SAMS

Learning-Windows-Phone7-Programming

 

Learning Windows Phone Programming


By Yochay Kiriaty, Jaime Rodriguez

Published by O’Reilly

More info

Programming-Windows-Phone7-Series

 

Programming Windows Phone 7
by Charles Petzold
Published by Microsoft Press
More info

Windows-Phone7-Application-Development-Using-Silverlight

 

Windows Phone 7 Application Development (Developer's Library)
by Corey Schuman
Published by Addison-Wesley Professional

XNA-Game-Studio-4.0-Programming-Developing-For-Windows-Phone-and-Xbox-Live

 

XNA Game Studio 4.0 Programming: Developing for Windows Phone and Xbox Live (Developer's Library)
by Tom Miller, Dean Johnson
Published by Addison-Wesley Professional

 

 

Beginning Windows Phone 7 Application Development: Building Windows Phone Applications Using Silverlight and XNA
by Nick Lecrenski, Karli Watson, Robert Fonseca-Ensor
Published by Wrox

 

 

Professional Windows Phone 7 Game Development: Creating Games using XNA Game Studio 4

by Chris G.Williams, George W. Clingerman
Published by Wrox