WP7 - 从我分配的页面恢复
假设我有两个页面 MainPage 和 DetailsPage。在详细信息页面中,用户点击开始按钮,然后点击后退按钮进入上一页。如果我们没有逻辑删除编码,它们将具有空白页面。
是否可以从主页恢复应用程序(不是详细信息页面)当他们点击后退按钮时。
亲切的问候。
Lets assume I have two pages MainPage and DetailsPage. In details page user hits on start button then hits on the back button to get to the Previous Page. And If we don't have tombstone coding they will have blank page.
Is it possible to resume the application from the MainPage (not the detailspage) when they hit back button.
Kind regards.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定这是否可以通过内置代码路径实现,但您可以使用
PhoneApplicationService.Activated
事件检测手机何时从逻辑删除激活。发生这种情况时,您可以直接或通过按程序化后退按钮手动将手机导航到主页。但我会反对所有这些。您的应用程序应将数据序列化到隔离存储并正确恢复。我认为这是用户希望在 WP7 应用程序中看到的预期行为。
http://www.imaginativeuniversal.com /blog/post/2010/08/22/WP7-Tombstoneing-Pattern-Tip.aspx
更新: 来自克劳斯下面的评论。您还可以使用 URL 上的查询字符串。当应用程序被逻辑删除时,这会自动保留。该查询字符串可用于再次触发数据加载,从而避免序列化整个集合。在您的情况下,您似乎正在从网络获取数据,因此查询字符串将非常适合您。
但是,您需要权衡这与增加用户手机数据计划的压力。如果序列化该集合是一个廉价的操作,我会说走这条路。
I'm not sure if this is possible via a built-in code path, but you can detect when the phone is activating from tombstone using the
PhoneApplicationService.Activated
event. When this occurs, you could manually navigate the phone to your main page either directly or via programmatic back button presses.I would argue against all of that though. Your app should serialize the data to isolated storage and restore it properly. This is the expected behaviour users will want to see inside WP7 apps in my opinion.
http://www.imaginativeuniversal.com/blog/post/2010/08/22/WP7-Tombstoning-Pattern-Tip.aspx
Update: from Claus in the comments below. You can also utilise the query string on the URL. This is automatically persisted when the app is tombstoned. This query string can be used to trigger the loading of data again, to save you from serializing the entire set. In your case it looks as though you are fetching data from the web, so the query string will work well for you.
However, you need to weigh that against adding pressure to the user's phone data plan. If serializing the set is a cheap action, I'd say go that route.