How to determine when a theme is changed in WP7?

My application is fully aware of the topic. When my application is disabled and the user changes the theme from dark to light (say) and returns to my application, the theme is not updated. Despite the fact that the phone theme is light, my application is still dark.

I made several attempts, but they report the same values. I declared a variable called isDarkThemeSelected, saved the value in a deactivated event, changed the theme, and returned to my application. But when the activated event is raised, the value of the variable remains unchanged.

Do you have a solution?

+6
source share
1 answer

Add this code to your homepage constructor:

var v = (Visibility)Resources["PhoneLightThemeVisibility"]; Debug.WriteLine("Using " + (v == Visibility.Visible ? "light" : "dark") + " theme"); 

(It detects the current topic and writes to the output window what it is.)

Then launch the application, look at the output in Visual Studio, close the application, change the theme, start the application and look again. If for the first time and for the second time it says different things, then your application is not as important as you think.

Edit: It seems that this does not always work due to a Mango error. The theme remains unchanged when you switch to the application after changing the theme. Only when the user restarts the application from the list of applications to which the new theme applies.

+6
source

Source: https://habr.com/ru/post/901466/


All Articles