开发者

Is there a bug when changing themes when app is deactivated and reactivated in Windows Phone Mango

开发者 https://www.devze.com 2023-04-03 05:43 出处:网络
Edit: This is under windows 7.1 开发者_如何学JAVARC. (This code did work for 7.0) Lets say we open the application up in the dark theme. A line of code to detect this would be as follows:

Edit: This is under windows 7.1 开发者_如何学JAVARC. (This code did work for 7.0)

Lets say we open the application up in the dark theme. A line of code to detect this would be as follows:

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

In this case, isDarkTheme will be true. Now hit the windows key, change your theme to light theme. and hit the back button to go back to your application. Run the following line of code again (in your activated event)

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

Apparently isDarkTheme is still true even though we switched themes. Has anyone else ran into this problem or am I using an older way to check the current theme?


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

That being said, it is unlikely that the user will reproduce this behavior. If he switched from your app to phone settings, chances are he is not going back via the back button.

0

精彩评论

暂无评论...
验证码 换一张
取 消