如何在 WP 中重新激活应用程序时刷新日期时间
我想知道当应用程序从 WP7.5 中的停用状态返回时是否可以刷新日期时间。我的应用程序基本上是日历类型,当应用程序启动时,当天会突出显示。
因此,如果我启动应用程序,然后按开始按钮,我的应用程序将进入停用状态,然后转到设置并更改时区,自然日期和时间可能会更改,然后返回到我的应用程序,它会保留旧日期。
例如。 假设当前日期是 20,我们更改日期为 19 的时区,理想情况下我的应用程序应该突出显示 19,但事实并非如此。我假设它在应用程序进入停用状态之前变为,它存储所有状态,并且当它返回时,它加载相同的数据。无论如何我可以刷新日期时间吗?
阿尔法
i would like to know if it is possible to refresh date time when the app returns from a deactivated state in WP7.5. My app is basically a calendar type and when the app starts the current day is highlighted.
So if i start the app, then press the start button, my app goes to deactivated state, then go to settings and change the time zone, naturally the date and time may change and then come back to my app, it retains the old date.
eg.
Suppose current date is 20 and we change the timezone where the date is 19, ideally my app should highlight 19, but it does not. I assume that its becomes before the app goes into deactivated state, it stores all the states and when it returns, it loads the same data. Is there anyway i could refresh the datetime?
Alfah
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我已经有一段时间没有进行任何 WP7 开发了,但我确信重新激活应用程序时会引发一个事件 - 您不能只查询
DateTime.Now
或DateTime.今天
那个时候?编辑:查看文档,我认为您想要 启动 和 已激活事件。 (
启动
,以便您即使在首次启动时也能检查时间;激活
,用于在休眠后重新激活。)It's been a while since I've done any WP7 development, but I'm sure there's an event raised when the app is reactivated - can't you just query
DateTime.Now
orDateTime.Today
at that point?EDIT: Looking at the docs, I think you want the Launching and Activated events. (
Launching
so that you check the time even on the initial launch;Activated
for reactivation after becoming dormant.)假设您有一个模型类,其中包含名为
DateToDisplayAsToday
的 DateTime 字段,并且该模型可在 App.XAML 中访问,您将需要在 App.xaml.cs 中执行以下操作Assuming that you have a model class that contains a DateTime field called
DateToDisplayAsToday
, and that model is accessible within App.XAML, you will want to to the following in App.xaml.cs