Derik Whittaker



How to detect the theme being used in WP7

As the Windows Phone 7 have either a dark (black) or light (white) theme which can be applied it will become very important for you to know which theme the user enabled in order to determine your applications color schema, this is assuming you are using styles which are not built into the skinning on WP7.

Sadly detecting the current theme is a bit hackish as it requires you to take a look at a current loaded resource to determine the theme.  I would have hoped that this would be part of the built in SDK as I see this as a common need for many applications.

Here is how you determine which theme is being used.

Color themeColor = (Color)Application.Current.Resources["PhoneForegroundColor"];
if (themeColor.ToString() == "#FFFFFFFF")
    this.PageTitle.Text = "Dark ";       
else if (themeColor.ToString() == "#DE000000")
    this.PageTitle.Text = "Light ";    

As you can see the code to determine the theme is easy, but not clean in my opinion.

Till next time,

Posted 07-27-2010 5:07 AM by Derik Whittaker
Filed under:



Oleksandr Krakovetskiy blog wrote Дайджест технических материалов #5 (Windows Phone 7)
on 10-27-2010 6:55 AM

Tools, Books, Guides Windows Phone 7 Developer Tools RTM (online installer) , ISO UI Design and Interaction

About The CodeBetter.Com Blog Network
CodeBetter.Com FAQ

Our Mission

Advertisers should contact Brendan

Google Reader or Homepage Latest Items
Add to My Yahoo!
Subscribe with Bloglines
Subscribe in NewsGator Online
Subscribe with myFeedster
Add to My AOL
Furl Latest Items
Subscribe in Rojo

Member Projects
DimeCasts.Net - Derik Whittaker

Friends of
Red-Gate Tools For SQL and .NET


SmartInspect .NET Logging
NGEDIT: ViEmu and Codekana
NHibernate Profiler
Balsamiq Mockups
JetBrains - ReSharper
Web Sequence Diagrams
Ducksboard<-- NEW Friend!


Site Copyright © 2007 CodeBetter.Com
Content Copyright Individual Bloggers


Community Server (Commercial Edition)