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”]; } –