Windows Phone 7:确定在 Application_Activated 事件期间激活哪个页面
当重新激活逻辑删除的应用程序时,我遵循恢复持久和非持久状态和对象的一般最佳实践原则。 中找到
可以在这篇非常好的微软文章此处
这些示例仅显示了一个简单的重新激活应用程序的主页。然而,由于我的应用程序有多个页面(其中任何一个页面都可以被逻辑删除并因此重新激活),并且每个页面都绑定到不同的 ViewModel 对象。我想知道如何确定最终将激活哪个页面,以便我可以有选择地反序列化并恢复该页面的正确 ViewModel 对象。
或者是恢复所有 ViewModel 的最佳实践还是有其他设计模式?
I am following the general best practice principles of restoring my persistent and none persistent state and objects when a tombstoned app is re-activated. Which can be found in this very good Microsoft article
The samples only show a simple re-activation of the main page of an app. However as my application has multiple pages (any of which could be tombstoned and therfore re-activated) and each one is binding to a different ViewModel object. I would like to know how to ascertain which page is ultimately going to be activated so that I can selectivly deserialize and recover the correct ViewModel object for that page.
Or is the best practice to restore all ViewModels or is there another design pattern for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我实现了一个简单的模式,最好描述为 -
我正在使用 Laurent Bugnion 出色的适用于 Windows Phone 7 的 MVVMLight 库。下面是一些说明消息广播的示例代码 -
在 ViewModel 类的构造函数中,我设置了对通知消息的订阅 -
我发现使用此策略,与绑定到 ViewModel 的页面相关的所有数据都会被保存并正确恢复。
HTH,indyfromoz
I have implemented a simple pattern that is best described as -
I am using Laurent Bugnion's excellent MVVMLight library for Windows Phone 7. Here is some sample code illustrating the message broadcast -
Within the constructor of a ViewModel class, I setup the subscription to the notification messages -
I found that with this strategy, all the data relevant to the page that is bound to a ViewModel is saved and restored properly.
HTH, indyfromoz