0
,而在應用程序啓動如何堅持IsolatedStorageSettings終止應用程序
我使用的異常終止對backevents如何留住保存isolatedstoragesettings後:
protected void _BackKeyPress(object sender, CancelEventArgs e)
{
if (MessageBox.Show("Do you want to close the application?", "Q", MessageBoxButton.OKCancel) != MessageBoxResult.OK)
{
e.Cancel = true;
System.IO.IsolatedStorage.IsolatedStorageSettings.ApplicationSettings.Add("key2", "33r4 ");
}
else
{
if (IsolatedStorageSettings.ApplicationSettings.Contains("Key"))
{
IsolatedStorageSettings.ApplicationSettings["Key"] = App.Current.ViewModel;
}
else
{
IsolatedStorageSettings.ApplicationSettings.Add("Key", App.Current.ViewModel);
}
throw new Exception("ExitApplication");
}
}
我試圖挽救它聲明在應用程序的視圖模型.xaml.cs,但無法在啓動時獲取其中的獨立存儲設置值。但它編譯並運行成功。
嗨,我已經用在其他部分,當我們按下「確定」關閉應用程序。 –
問題是你需要在設置新值後調用它。在你的情況下,就在通過throw new Exception退出之前。你應該嘗試使用我的代碼,我認爲它會起作用。 –