在 WP7 应用程序中组织 ViewModel 的最佳方式是什么?

发布于 2024-12-01 00:29:49 字数 231 浏览 1 评论 0原文

我需要显示从图书应用程序的本地 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

看透却不说透 2024-12-08 00:29:49

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文