2010-11-21 3 views
6

휴대 전화의 "테마"(예 : 밝음 또는 어두움)를 내 코드에서 어떻게 알 수 있습니까?Windows Phone 7 배경 테마 설정 - 앱 개발

UPDATE :

확인, 좀 더 연구를하고 이후에 내가 무엇을해야 보이는 뭔가를 찾을 수 있었다. 그러나, 아마도 더 좋은 방법이 있을까요?

생각하십니까? 여기

내가 그 지금은 내 질문에 대한 답을 찾을 것입니다 : 순간

var backColor = Resources["PhoneBackgroundColor"]; 
+0

RGB이 작품 값들하지만 확인 새로운 "PhoneLightThemeVisibility"
지금이 일을 선호하는 방법은 (확인 RGB 값이 여전히 작동하더라도)과 같은 "PhoneLightThemeVisibility"의 표시 여부를 확인한다 리소스가 선호됩니다 - 내 대답을 참조하십시오. – mikeesouth

+0

http://www.kirupa.com/windowsphone/detecting_the_theme.htm –

+0

https://github.com/ZombieHunter/WP7-Theme – CodeZombie

답변

9

초기 베타 버전에서는 다른 사람들이 지적한 것처럼 PhoneBackgroundColor의 RGB 값을 확인하는 방법이 있습니다. 그러나 이것은 바뀌었다.

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

HTH

+0

+1 좋은 방법입니다. – keyboardP

3

, PhoneBackgroundColor의 값이 테마를 검출하는 방법으로 인정 될 것으로 보인다 검사합니다. 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 

} 

} 
+0

RGB 값 확인은 새로운 "PhoneLightThemeVisibility"자원에서 작동합니다. 선호 - 내 대답을 참조하십시오. – mikeesouth