Windows Phone 7 Theme Background - Application Development

How can I say in my code that the “theme” of the phone is turned on (i.e. light or dark)?

UPDATE:

Well, after a little research, I was able to find something that seems to do what I need. However, maybe there is a better way?

Thoughts?

Here is what I found that answers my question:

var backColor = Resources["PhoneBackgroundColor"]; 
+6
windows-phone-7
source share
2 answers

In early beta versions, the way to do this is by checking the RGB values ​​of PhoneBackgroundColor, as others have pointed out here. However, this has changed. Now the preferred way to do this is to check the visibility of “PhoneLightThemeVisibility” as such (even if checking RGB values ​​still works):

 Visibility v = (Visibility)Resources["PhoneLightThemeVisibility"]; if (v == System.Windows.Visibility.Visible) { // Light theme } else { // Dark theme } 

NTN

+9
source share

At the moment, checking the value of PhoneBackgroundColor seems to be an acceptable method of detecting a theme. You can check the value by the following code: this post .

 private Color lightThemeBackground = Color.FromArgb(255, 255, 255, 255); private Color darkThemeBackground = Color.FromArgb(255, 0, 0, 0); private void DisplayState() { SolidColorBrush backgroundBrush = Application.Current.Resources["PhoneBackgroundBrush"] as SolidColorBrush; if (backgroundBrush.Color == lightThemeBackground) { // you are in the light theme } else { // you are in the dark theme } } 
+3
source share

All Articles