Derik Whittaker

Syndication

News


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:

[Advertisement]

Comments

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

Subscribe
Google Reader or Homepage

del.icio.us CodeBetter.com Latest Items
Add to My Yahoo!
Subscribe with Bloglines
Subscribe in NewsGator Online
Subscribe with myFeedster
Add to My AOL
Furl CodeBetter.com Latest Items
Subscribe in Rojo

Member Projects
DimeCasts.Net - Derik Whittaker

Friends of Devlicio.us
Red-Gate Tools For SQL and .NET

NDepend

SlickEdit
 
SmartInspect .NET Logging
NGEDIT: ViEmu and Codekana
LiteAccounting.Com
DevExpress
Fixx
NHibernate Profiler
Unfuddle
Balsamiq Mockups
Scrumy
JetBrains - ReSharper
Umbraco
NServiceBus
RavenDb
Web Sequence Diagrams
Ducksboard<-- NEW Friend!

 



Site Copyright © 2007 CodeBetter.Com
Content Copyright Individual Bloggers

 

Community Server (Commercial Edition)