2014-08-28 1 views
0

내 앱에 10 페이지가 있으며 모두 검은 색 배경입니다. 내 애플 리케이션에서 radioButton을 사용하여 모든 페이지의 배경색을 사용자가 바꿀 수있게하고 싶다. 가장 쉬운 방법으로 이것을 어떻게 할 수 있습니까?WP7 - 사용자가 앱 테마를 설정하는 방법

답변

0

2. Windows Phone Mango Custom application Theme

이 당신에게 도움이 될 수있는이 블로그

1. Theme Forcing for Windows Phone 7 또는를 통해 이동합니다. 이것들을 연구하고 수정하여 설정 페이지에 넣을 수 있습니다.

는 10 페이지가 각 페이지에서 설정 메뉴를 통해 해당 페이지의 배경색을 변경하려면, 그래서 당신은

+0

잘못된 단어를 사용했을 수도 있습니다. 내 앱의 설정 페이지에서이 색상을 사용자가 변경할 수있게하고 싶습니다. – petros

0

좋아 :) 감사합니다. Windows Phone IsolatedStorageSettings을 사용하면됩니다.

먼저 IsolatedStorageSettings를 초기화하려고합니다. 다음과 같이 할 수 있습니다.

IsolatedStorageSettings MyAppSettings = IsolatedStorageSettings.ApplicationSettings; 

그런 다음 예외가 발생하지 않도록 기본값을 설정해야합니다. 이 작업을 수행 할 수 있습니다

private void Application_Launching(object sender, LaunchingEventArgs e) 
{ 

if (IsolatedStorageSettings.ApplicationSettings.Contains("PageBackgroundColor")) 
     { 
      // Don't do anything because you've already set the default background colour for the pages 
     } 
     else 
     { 
      // add the default color 
     } 
} 

지금 당신의 MainPage에 당신이 IsolatedStorageSettings를 다시 초기화 할 수 있습니다

MyAppSettings.Add("PageBackgroundColor", "#000000"); // you can set whatever the default colour you want here. i.e. Black 

내가있을 거라고 생각 최고의 장소는이 코드를 추가하는 것입니다. 일단 설정 값을 얻고 싶으면 값에 따라 배경색을 변경해야합니다. 값을 읽으려면 :

protected override void OnNavigatedTo(NavigationEventArgs e) 
{ 

} 

또는 지금

public MainPage 
{ 
    InitializeComponent(); 
} 

Remember that public MainPage will only run once and the OnNavigatedTo runs every time the page is loaded so if you want to update the background color right after adding the setting, OnNavigatedTo is the way to go but if you want to apply the changes after a restart, public Mainpage is it.

이 값을 읽어 그것에게 당신을 변경

string Sortval = (string)MyAppSettings["PageBackgroundColor"]; 

당신은이를 추가 할 수 있습니다 다음과 같이하고 싶습니다.

0 이제
string val = (string)MyAppSettings["PageBackgroundColor"]; 
if (val == "#000000") 
{ 
    //change to black 
} 
else if (val == "your hex color") 
{ 
    //change to whatever color 
} 
else if (val == "another hex color") 
{ 
    //... 
} 

당신이 당신의 설정 페이지에서 IsolatedStorageSettings를 다시 초기화하고이 같은 것 값을 저장할 값을 저장 : 그것은 당신에게 매우 주어야한다

MyAppSettings.Remove("PageBackgroundColor"); 
MyAppSettings.Add("PageBackgroundColor", "your hex color"); 
MyAppSettings.Save(); 

이 그러나 안된를 설정을 저장하고로드하는 측면에서 기본 설정을 적용한 다음 적용하는 방법에 대한 기본 아이디어

관련 문제