有关 Windows Phone 7 中的逻辑删除的问题
我有一个奇怪的问题:我导航到一个视图,检查一个或多个 CheckBox
并导航回来(我没有重写 navigateFrom
方法)。然后我再次导航到我的视图,并且该复选框未被选中。
这是正常行为吗?我是 Windows Phone 7 的墓碑“功能”的一部分吗?如果是,这是否意味着每当我从视图导航时,即使它在我的应用程序中,我也需要保存状态? (是的,这很糟糕……)
I have a weird probleme : I navigate to a view, I check one or more CheckBox
and navigate back (I didn't override the navigateFrom
method). Then I navigate to my view again, and the checkbox aren't checked.
Is this even normal behavior ? I this part of the tombstonning "feature" of Windows Phone 7 ? If yes, does that mean that whenever I navigate from a view, even if its within my app, I need to save state ? (I yes, that sucks...)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
听起来您正在做的是:
如果这就是您正在做的事情,那么这就是发生的情况。
在第 3 点,页面被销毁。如果您没有保存某些内容,那么系统不会神奇地为您保存它。
在第 4 点中,创建了一个全新的页面。如果您没有编写任何代码来设置 UI 状态,那么它将是默认状态。
据推测,复选框的选中状态代表应用程序中的其他内容。因此,您可能应该考虑将其检查状态绑定到基础设置。
因为系统无法知道什么是您想要保留的更改,什么不是,所以它让您自行决定。
通常最好在数据或设置更改后立即保存。无论在应用程序中进行导航,您的应用程序都可能随时被逻辑删除,并且您可能希望保留应用程序及其数据/状态,以便用户不会因逻辑删除而丢失任何内容或感到困惑。
It sounds like what you're doing is:
If that's what you're doing, here's what's happening.
In point 3 the page is destroyed. If you didn't save something then the sytem won't have magically saved it for you.
In point 4 a brand new page is created. If you haven't written any code to set up the UI state then it will be the default.
Presumably the checked state of the checkbox is representative of something else in your app. You should therefore probably look at binding it's checked state to the underlying setting.
Because the system can't know what is a change you want persisting and what isn't, it leaves this up to you.
It's normally best to save data or setting changes as soon as they are made. Regardless of navigating within your application, your app could get tombstoned at any point and you'll probably want to preserve the app and it's data/state so that the user doesn't lose anything or get confused as a result of tombstoning.