0
正如在此問題的標題中所述,我試圖在應用程序關閉時保留Timespan值。這就是情況......我正在編寫一個Windows小工具,每當彈出窗口關閉時就會銷燬它,以及Timespan值。我需要它,所以每次關閉彈出窗口時都會保留這個值,這將如何完成?在退出時保留Silverlight應用程序中的值
我現在正在做的代碼如下。
SilverlightGadgetUtilities.Stopwatch watch = new SilverlightGadgetUtilities.Stopwatch();
private void Application_Startup(object sender, StartupEventArgs e)
{
watch.currentTime();
this.RootVisual = new Page();
}
private void Application_Exit(object sender, EventArgs e)
{
watch.currentTime();
}
這是我的秒錶類:
public TimeSpan? currentTime()
{
current = Elapsed;
return current;
}
public TimeSpan? Elapsed
{
get
{
return new TimeSpan(this.GetElapsedDateTimeTicks() * 10000000);
}
}
凡GetElapsedDateTimeTicks()
使用DateTime.Now.Second()
的時機。再次
謝謝!
我得到一個錯誤「的項目鍵已經添加'我需要在使用前實例化一個新的? –
*錯誤我的意思是異常。 –
嘗試IsolatedStorageSettings.ApplicationsSettings [「MySettingName」] = MySetting;代替。在嘗試訪問它之前,請確保它存在。例如:if(IsolatedStorageSettings.ApplicationSettings.Contains(「MySettingName」)) {var setting = IsolatedStorageSettings.ApplicationSettings [「MySettingName」]; } –