在 WP7 应用程序中组织 ViewModel 的最佳方式是什么?
我需要显示从图书应用程序的本地 XML 读取的数据。我必须以不同的方式显示数据,例如。作者列表、编辑列表、流派列表等,然后显示书籍详细信息。
组织 ViewModel 的最佳方式是什么?我可以有一个带有各种 GetAuthors、GetEditors 等的 BooksViewModel 类,还是应该有 AuthorsViewModel、EditorsViewModel 等?
数据存在于本地 XML 中且无法更改。
I need to show data reading from local XML for a books app. I have to show data in different ways, eg. list of authors, list of editors, list of genres, etc then showing the book details.
Which is the best way to organize ViewModels? Can I have a single BooksViewModel class with the various GetAuthors, GetEditors, etc or should I have AuthorsViewModel, EditorsViewModel, etc?
Data is present in local XML and cannot change.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ViewModel 跟随视图。因此,如果您希望显示其信息的每种类型都有一个单独的视图(页面),那么是的,多个视图模型是有意义的。
但是,如果您的所有数据都有一个视图(例如一个数据透视表),然后每个数据类型都有一个单独的数据透视项,那么您将使用具有多个可观察属性的单个视图模型。
The ViewModel follows the view. So if you're having a separate view (page) for each type you wish to display the information for, then yes, several viewmodels makes sense.
But if your for instance, have a single view for all the data, for example a pivot, and then having a individual pivotitem for each data type, then you would use a single viewmodel, with several observable properties.