Is there an error when changing themes when the application is disconnected and activated in Windows Phone Mango

Edit: this is under Windows 7.1 RC. (This code really works for 7.0)

Let's say we open the app in a dark theme. A line of code to detect this will look like this:

isDarkTheme = (Visibility.Visible == (Visibility)Application.Current.Resources[StringResource.PhoneDarkThemeVisbility]); 

In this case, isDarkTheme will be true. Now press the Windows key, change the theme to a light theme. and click the back button to return to your application. Repeat the following line of code (in the activated event)

  isDarkTheme = (Visibility.Visible == (Visibility)Application.Current.Resources[StringResource.PhoneDarkThemeVisbility]); 

Apparently isDarkTheme is still true, although we switched themes. Has anyone else encountered this problem or am I using the old way to check the current topic?

+4
source share
1 answer

This is a known issue. The theme is applied to your application when it starts, so only then can you correctly determine whether the light or dark setting is used. Otherwise, you are stuck with the old theme until the application restarts.

Speaking of which, it is unlikely that the user will reproduce this behavior. If he switches from your application to your phoneโ€™s settings, most likely he wonโ€™t return via the back button.

+4
source

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


All Articles