How to force a WindowsPhone app to use a specific Theme?


It happens sometime that a specific theme like Light or Dark looks good in some application. In such case, you have to specify all the colours manually to background foreground etc. This is very hectic job. Is there any easy way doing this?

 

Yes, we have. Jeff Wilcox simplified this process by releasing a ThemeManager library (open source) for you which you can use in your app and force a specific theme for your Windows Phone application.

 

ThemeManager library is an open source library available in NuGet and also in GitHub, which you can freely use in your Windows Phone app and force a specific theme (Light or Dark) to the app. Also, you can inverse the theme for your app based on system theme.

 

Remember that, you can not change the theme at runtime depending on users input. You have to change it once at the time of app load (in App.xaml.cs file, just after the initialization). ThemeManager class is available under the Microsoft.Phone.Controls namespace.

 

// call ToLightTheme() to force Light Theme of the app
ThemeManager.ToLightTheme();
 
// call ToDarkTheme() to force Dark Theme of the app
ThemeManager.ToDarkTheme();
 
// call InvertTheme() to invert the Theme of the app based on system Theme
ThemeManager.InvertTheme();

 

This ThemeManager class also exposes a static method named CreateApplicationBar(). If you want to theme the application bar, you should call CreateApplicationBar() method and that will automatically apply the theme.

 

To include the ThemeManager library in your application project, install it from NuGet Package Manager by entering the following command:

 

Install ThemeManager library from NuGet Package Manager

 

You can also download the source from the NuGet Package Manager. Here is the command for that:

 

Install ThemeManager library source from NuGet Package Manager

 

To know more about the library, read the following blog post from the author Jeff Wilcox: “PhoneThemeManager: allow your app to have the Light, Dark, or Inverted theme with 1 line of code”.

 

If you came to know about the library from this blog post, visit the above link to  find out more. I hope, this will now help you to properly theme your Windows Phone application and also will help you to force a specific theme to your app.

 

Related Links

 


If you have come this far, it means that you liked what you are reading. Why not reach little more and connect with me directly on Twitter, Facebook, Google+ and LinkedIn. I would love to hear your thoughts and opinions on my articles directly. Also, don't forget to share your views and/or feedback in the comment section below.

1 comments

 
© 2008-2016 Kunal-Chowdhury.com - Microsoft Technology Blog for developers and consumers | Designed by Kunal Chowdhury
Back to top