I have developed a windows phone application, i want that app to be run in light theme, irrespective of what user have set. means is there any way to set a default theme for the windows phone 8 app.
4 Answers
You can use Jeff Wilcox's ThemeManager
Add it to your project (there is a NuGet package available) and call it from App()
constructor.
public App()
{
// Global handler for uncaught exceptions.
UnhandledException += Application_UnhandledException;
// Standard Silverlight initialization
InitializeComponent();
// Phone-specific initialization
InitializePhoneApplication();
ThemeManager.ToLightTheme();
// Other code that might be here already...
}
You can find usage example on his website.

- 9,105
- 1
- 28
- 39
-
which nuget package is required here ? – Kuldeep Singh Oct 09 '13 at 13:53
-
Did you click the link? You'll be navigated directly to the package page. – Anton Sizikov Oct 09 '13 at 13:55
-
Too bad that it is not supported for windows phone 8.1 – JP Hellemons Jun 26 '14 at 12:51
-
For SL for 8.1 application you can just get a source code and compile it. – Anton Sizikov Jun 30 '14 at 13:52
-
For 8.1 apps, check out this http://www.jayway.com/2014/04/17/windows-phone-8-1-for-developers-theme-resources/ – Thuy Trinh Dec 18 '14 at 10:02
-
PM> Install-Package PhoneThemeManager - to install this via nuGet – Fiach Reid Oct 27 '15 at 17:56
For Windows phone 8.1 you can use:
<Application
x:Class="App26.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
RequestedTheme="Light"
xmlns:local="using:App26">
</Application>
Or
public App()
{
this.RequestedTheme = ApplicationTheme.Light;
this.InitializeComponent();
this.Suspending += this.OnSuspending;
}
Source : Windows phone 8 How to be always on one theme even if phone's theme changed
From http://developergoodies.blogspot.nl/2012/10/force-windows-phone-theme.html
(Tested and verified; get the themes; copied from resource to prevent future inaccessibility)
Answer
When the UI is designed specially for the dark theme it won't look well on the light theme, or vice versa.
To prevent this the application can force the default dark or light theme.
In the application class' constructor put this code to force the dark theme:
if ((Visibility)Application.Current.Resources["PhoneLightThemeVisibility"] == Visibility.Visible) MergeCustomColors("/Themes/DarkStyles.xaml");
Or this code to force the light theme:
if ((Visibility)Application.Current.Resources["PhoneDarkThemeVisibility"] == Visibility.Visible) MergeCustomColors("/Themes/LightStyles.xaml");
Anywhere in your project put this method:
private void MergeCustomColors(String Theme)
{
ResourceDictionary Dictionaries = new ResourceDictionary();
String source = String.Format(Theme);
var themeStyles = new ResourceDictionary { Source = new Uri(source, UriKind.Relative) };
Dictionaries.MergedDictionaries.Add(themeStyles);
ResourceDictionary appResources = Current.Resources;
foreach (DictionaryEntry entry in Dictionaries.MergedDictionaries[0])
{
SolidColorBrush ColorBrush = entry.Value as SolidColorBrush;
SolidColorBrush ExistingBrush = appResources[entry.Key] as SolidColorBrush;
if (ExistingBrush != null && ColorBrush != null) { ExistingBrush.Color = ColorBrush.Color; }
}
}
The code assumes that the projects contains the files DarkStyles.xaml and LightStyles.xaml in a folder named Themes.

- 8,582
- 6
- 44
- 82
-
exception at the line : var themeStyles = new ResourceDictionary { Source = new Uri(source, UriKind.Relative) }; – Kuldeep Singh Oct 09 '13 at 13:25
-
Did you add the `LightStyles.xaml` file to the Themes folder (as the answer describes)? – Deathspike Oct 09 '13 at 13:27
-
but its like making arrangement to get the result. is there any global solution for this ? – Kuldeep Singh Oct 09 '13 at 13:32
Call this method in your app constructor
private void LightTheme()
{
((SolidColorBrush)Resources["PhoneRadioCheckBoxCheckBrush"]).Color = ((SolidColorBrush)Resources["PhoneRadioCheckBoxBorderBrush"]).Color = ((SolidColorBrush)Resources["PhoneForegroundBrush"]).Color = Color.FromArgb(0xDE, 0x00, 0x00, 0x00);
((SolidColorBrush)Resources["PhoneBackgroundBrush"]).Color = Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF);
((SolidColorBrush)Resources["PhoneContrastForegroundBrush"]).Color = Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF);
((SolidColorBrush)Resources["PhoneContrastBackgroundBrush"]).Color = Color.FromArgb(0xDE, 0x00, 0x00, 0x00);
((SolidColorBrush)Resources["PhoneDisabledBrush"]).Color = Color.FromArgb(0x4D, 0x00, 0x00, 0x00);
((SolidColorBrush)Resources["PhoneProgressBarBackgroundBrush"]).Color = Color.FromArgb(0x19, 0x00, 0x00, 0x00);
((SolidColorBrush)Resources["PhoneTextCaretBrush"]).Color = Color.FromArgb(0xDE, 0x00, 0x00, 0x00);
((SolidColorBrush)Resources["PhoneTextBoxBrush"]).Color = Color.FromArgb(0x26, 0x00, 0x00, 0x00);
((SolidColorBrush)Resources["PhoneTextBoxForegroundBrush"]).Color = Color.FromArgb(0xDE, 0x00, 0x00, 0x00);
((SolidColorBrush)Resources["PhoneTextBoxEditBackgroundBrush"]).Color = Color.FromArgb(0x00, 0x00, 0x00, 0x00);
((SolidColorBrush)Resources["PhoneTextBoxReadOnlyBrush"]).Color = Color.FromArgb(0x2E, 0x00, 0x00, 0x00);
((SolidColorBrush)Resources["PhoneSubtleBrush"]).Color = Color.FromArgb(0x66, 0x00, 0x00, 0x00);
((SolidColorBrush)Resources["PhoneTextBoxSelectionForegroundBrush"]).Color = Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF);
((SolidColorBrush)Resources["PhoneButtonBasePressedForegroundBrush"]).Color = Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF);
((SolidColorBrush)Resources["PhoneTextHighContrastBrush"]).Color = Color.FromArgb(0xDE, 0x00, 0x00, 0x00);
((SolidColorBrush)Resources["PhoneTextMidContrastBrush"]).Color = Color.FromArgb(0x73, 0x00, 0x00, 0x00);
((SolidColorBrush)Resources["PhoneTextLowContrastBrush"]).Color = Color.FromArgb(0x40, 0x00, 0x00, 0x00);
((SolidColorBrush)Resources["PhoneSemitransparentBrush"]).Color = Color.FromArgb(0xAA, 0xFF, 0xFF, 0xFF);
((SolidColorBrush)Resources["PhoneInactiveBrush"]).Color = Color.FromArgb(0x33, 0x00, 0x00, 0x00);
((SolidColorBrush)Resources["PhoneInverseInactiveBrush"]).Color = Color.FromArgb(0xFF, 0xE5, 0xE5, 0xE5);
((SolidColorBrush)Resources["PhoneInverseBackgroundBrush"]).Color = Color.FromArgb(0xFF, 0xDD, 0xDD, 0xDD);
((SolidColorBrush)Resources["PhoneBorderBrush"]).Color = Color.FromArgb(0x99, 0x00, 0x00, 0x00);
((SolidColorBrush)Resources["PhoneAccentBrush"]).Color = Color.FromArgb(0xFF, 0x00, 73, 99);
((SolidColorBrush)Resources["PhoneChromeBrush"]).Color = Color.FromArgb(0xFF, 0xDD, 0xDD, 0xDD);
}

- 21
- 5