如何在 WP7 ViewModelLocator 中处理 TombStoning
当我的 WP7 应用程序从逻辑删除状态恢复时,它会创建我存储在 App.Resources 中的 ViewModelLocator 类。你打算如何处理这个问题?在我的 ViewModelLocator 构造函数中,创建了多个 ViewModel,并且在这些构造函数中存在多个 WCF 服务调用。让此类每次从逻辑删除状态恢复时都重新创建似乎是错误的。
看来我需要在我的应用程序被逻辑删除之前序列化 ViewModelLocator,并在之后反序列化它。听起来正确吗??? MVVM-Light 中有什么东西可以处理这个问题吗?
When my WP7 app comes back from being Tombstoned, it creates the ViewModelLocator class that I have stored in App.Resources. How do are you suppose to handle this? In my ViewModelLocator constructor there are several ViewModels being created and in those constructors there are several WCF Service calls. It seems wrong to let this class be recreated every time it comes back from being tombstoned.
It seems like I need to serialize the ViewModelLocator before my app gets Tombstoned, and deserialize it after. Sound correct??? and is there something in MVVM-Light to handle this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您肯定需要保存数据才能在逻辑删除后恢复它。
MVVM Light为您提供MVVM框架,而不是WP7数据存储解决方案。您需要使用最适合您和独立存储的任何存储格式自行实现此目的。
下面是使用isolatedStorageSettings 的基本示例...WP7 SDK 提供的基于字典的抽象。
Win7 移动平台上的逻辑删除
You definitely need to save your data to be able to restore it after tombstoning.
MVVM Light provides the MVVM framework for you, not the WP7 data storage solution. You'll need to implement this yourself using whatever storage format is most suitable for you and Isolated Storage.
Here's a basic examples that uses IsolatedStorageSettings... a dictionary based abstraction provided by the WP7 SDK.
Tombstoning on the Win7 Mobile Platform