IsolatedStorage에서 읽고 쓰는 사용자 지정 클래스가 있습니다. 내 모든 가치는 이미지를 제외하고 제대로 저장되고 검색되고 있습니다. 여기에 내가 PhotoChooserTask를 사용하여 이미지를 수집하고 저장 위치를 IsolatedStorage 값을 저장하지 않음
다음//Transparent Background
public static readonly Setting<BitmapImage> TransparentBackground = new Setting<BitmapImage>("TransparentBackground", null);
결과가
Settings.Page을 IsolatedStorage하는 것입니다 내 설치
Setting.cs
//Encapsulates a key/value pair stored in Isolated Storage ApplicationSettings
public class Setting<T>
{
string name;
T value;
T defaultValue;
bool hasValue;
public Setting(string name, T defaultValue)
{
this.name = name;
this.defaultValue = defaultValue;
}
public T Value
{
get
{
//Check for the cached value
if (!this.hasValue)
{
//Try to get the value from Isolated Storage
if (!IsolatedStorageSettings.ApplicationSettings.TryGetValue(this.name, out this.value))
{
//It hasn't been set yet
this.value = this.defaultValue;
IsolatedStorageSettings.ApplicationSettings[this.name] = this.value;
}
this.hasValue = true;
}
return this.value;
}
set
{
//Save the value to Isolated Storage
IsolatedStorageSettings.ApplicationSettings[this.name] = value;
this.value = value;
this.hasValue = true;
}
}
public T DefaultValue
{
get { return this.defaultValue; }
}
// Clear cached value
public void ForceRefresh()
{
this.hasValue = false;
}
}
Settings.cs입니다 .xaml.cs
private void Browse_Click(object sender, RoutedEventArgs e)
{
photoChooserTask.Show();
}
void photoChooserTask_Completed(object sender, PhotoResult e)
{
if (e.TaskResult == TaskResult.OK)
{
//Code to display the photo on the page in an image control named TransparentModeViewBoxImage.
BitmapImage bmp = new BitmapImage();
bmp.SetSource(e.ChosenPhoto);
TransparentModeViewBoxImage.Source = Settings.TransparentBackground.Value = bmp;
}
}
동일한 응용 프로그램 인스턴스에서 MainPage 배경을 Settings.TransparentBackground.Value
으로 설정할 수 있습니다.이 응용 프로그램을 완전히 다시 시작하면 null이 반환되지만 Settings.TransparentBackground.Value
null로 돌아갑니다. I에 폐쇄시
MainPage.xaml.cs를 응용 프로그램에서 아무데도
ImageBrush ib = new ImageBrush();
if(Settings.TransparentBackground.Value == null)
//Use no background image
else
ib.ImageSource = Settings.TransparentBackground.Value;
LayoutRoot.Background = ib;
null로
Settings.TransparentBackground.Value
를 재설정합니다. 격리 된 저장소에이 값만 저장되지 않는 이유를 알 수 없습니다.