Follow us on X (Twitter)  Like us on Facebook  Connect with us on LinkedIn  Subscribe to our YouTube Channel  Subscribe to our WhatsApp Group

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

 

Have a question? Or, a comment? Let's Discuss it below...

Thank you for visiting our website!

We value your engagement and would love to hear your thoughts. Don't forget to leave a comment below to share your feedback, opinions, or questions.

We believe in fostering an interactive and inclusive community, and your comments play a crucial role in creating that environment.