Template10: Switching between Light/Dark theme does not show after app restart

Created on 7 Apr 2016  路  8Comments  路  Source: Windows-XAML/Template10

Been trying to figure this one out for a few hours now. Using the Hamburger template with no changes.

If I go to settings and switch to dark theme it'll change to dark theme, but if I close the app completely and opens it up again it has light theme applied even though the setting is still set on dark theme. This has been tried on both a Windows 10 desktop PC and on Windows 10 Mobile.

Been stepping through, and I suspect that the culprit is that the line
Views.Shell.HamburgerMenu.RefreshStyles(value);
has to be ran on the initiation of the shell view, but this is only triggered when the setting is set.

I've temporarily managed to solve this by adding these two lines in the Shell page constructor:
Services.SettingsServices.SettingsService _settings = Services.SettingsServices.SettingsService.Instance;
HamburgerMenu.RefreshStyles(_settings.AppTheme);

It doesn't feel like a good fix, but at least it's working for now. If there's a better way to accomplish this, please do tell.

Note: Tried using (ApplicationTheme)App.Current.RequestedTheme instead of _settings.AppTheme to avoid instantiating the SettingsService, but that did no difference, it even told me that it was set to light after the setting had been loaded in App constructor with dark as value..

bug

Most helpful comment

I have resolved this and it will be in today's NuGet update.

All 8 comments

Same issue here. Creating a brand new app (_any_ type) and running it, changing settings, then restarting it doesn't change the theme, even though it saves the theme settings.

Hey @IzaacJ and @RareNCool take a look here: https://github.com/NaylahProject/Template10.Reloaded
(Just run PlaygroundApp)

And tell me if it solves, them i will make PR's in the oficial repo.

@angusbreno Sorry, doesn't fix it. I'm on Build 14316, if that helps anything.

@RareNCool The application current theme start with the theme that u want? Have u tried set this like that:

https://github.com/NaylahProject/Template10.Reloaded/blob/master/Template10.Reloaded.PlaygroundApp/Views/MainView.xaml.cs#L32

?

Is it possible you are uninstalling your app between builds?
snip_20160414121540

I didn't open the issue but I have the same problem, and I don't have that checkbox checked.

What happens is that the toggle in Settings page is set to Dark theme but the Light one is loaded, probably because theme loading happens before Settings loading.
Adding Views.Shell.HamburgerMenu.RefreshStyles(value) (where value is taken from Settings) in Shell ctor fixed it.

Are you using individual style properties or are you using AccentColor?

I have resolved this and it will be in today's NuGet update.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JerryNixon picture JerryNixon  路  7Comments

resolutedreamer picture resolutedreamer  路  4Comments

HesamKashefi picture HesamKashefi  路  6Comments

JerryNixon picture JerryNixon  路  8Comments

marcinmarkiewicz picture marcinmarkiewicz  路  9Comments