0
朋友你好是新的Windows手機正在開發一個應用學習的Windows Phone 7 - 保存圖像狀態在獨立存儲
這是一個單頁的應用程序與一組圖像和基於Image_tap正在顯示圖像()它工作完美。現在我想保存圖像狀態(圖像源)時Application_closing,我想找回狀態Application_launching
在MainPage.xaml.cs中文件
PhoneApplicationService phoneAppservice = PhoneApplicationService.Current;
private void Image_Tap(object sender, GestureEventArgs e)
{
Image mybutton = (Image)sender;
image1.Source = mybutton.Source;
phoneAppservice.State["myValue"] = mybutton.Source;
}
private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
{
object value;
if (phoneAppservice.State.TryGetValue("myValue", out value))
{
image1.Source = (System.Windows.Media.ImageSource)value;
}
}
在
app.xaml.cs file:
private void Application_Launching(object sender, LaunchingEventArgs e)
{
getSource();
}
private void Application_Closing(object sender, ClosingEventArgs e)
{
saveSource();
}
private void saveSource()
{
PhoneApplicationService phoneAppservice = PhoneApplicationService.Current;
IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;
settings["myValue"] = phoneAppservice.State["myValue"];
}
private void getSource()
{
PhoneApplicationService phoneAppservice = PhoneApplicationService.Current;
IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;
object myValue;
if(settings.TryGetValue<object>("myValue", out myValue))
{
phoneAppservice.State["myValue"] = myValue;
}
}
am saving the getting ima ge源,並且不能將該源設置爲我的圖像。我覺得我失去了一些東西或請建議花葯正確的方式提前
感謝
什麼是'PhoneApplicationPage_Loaded'這裏保存在獨立存儲的狀態。它是MainPage的Loaded事件處理程序嗎?如果是這樣,在那裏放置一個斷點並告訴你在'value'字段中獲得了什麼值? – nkchandra
感謝您的重播..!我只是休閒chanal9視頻,適用於textBox值。現在我以前解決了這個問題,我試圖在狀態保存圖像源,我認爲這是錯誤的 – kartheek
如果你的問題解決了,然後發佈你的解決方案作爲答案。 – nkchandra