如何使用 MVVM 方法实现 DataGrid
我想使用 Datagrid(或列表)和 MVVM 模式实现一种地址簿/通讯录。
就像在 Outlook/Thunderbird 中一样,您会显示一个包含 2-3 个主要字段(例如姓名)的联系人列表,当您双击某个联系人时,您会看到一个新的模式框,其中显示所有内容该特定联系人的详细信息。
几周/几个月以来,我在网上阅读了很多有关 MVVM 模式的内容,但不知何故,我感到困惑。到目前为止,我可以找到任何这样的样本。 (也许,我搜索错了?)
我如何组织这样的应用程序?
更新:
我的场景与管理客户、订单和产品的应用程序非常相似。 用户将通过 3 个选项卡显示 3 个数据网格作为主视图,其中一个显示客户列表,一个显示订单,一个显示产品。
然后在每个视图中,您可以添加、删除(在某些条件下)对象。
每个对象都与另一个对象存在关系。
例如,在客户实例中,我有该客户的订单列表,以及每个订单的订购产品列表。
我想使用 MVVM 模式实现类似的东西?
有人可以帮忙吗,如何构建它?
某处有样本吗?
I'd like to implement a sort of Addressbook/Contactbook using a Datagrid (or a List) and the MVVM pattern.
Something like in Outlook/Thunderbird, where you've a list of your contacts displayed with a 2-3 main fields (name surname for example), and when you double-click a contact, then you get a new modal box that displays all the details of this specific contact.
Since a couple of weeks/months, I'm reading a lot of stuff about MVVM pattern on the net, but somehow, I get confused. Until now, I could find any sample like this. (perhaps, I searched wrong?)
How could I organize such an application?
Update:
My scenario is very similar to an application that manages Customers, Orders and Products.
The user would have as main view 3 datagrids shown through 3 tabs, one shows the list of Customers, one the Orders and one the Products.
Then in each view, you can Add, Delete (under certain conditions) an object.
Each object has a relation with another one.
For example, in a Customer instance, I've a list of Orders for that Customer and for each Order a list of Products ordered.
I'd like to implement something like this using the MVVM pattern?
Could someone help, how to structure it?
Is there a sample somewhere?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
像这样的东西?
编辑
我制作了一个简单的应用程序,它可以做什么您想要的源代码可以在这里找到< /a>
让我知道这是否是您想要的。
Some thing like this?
Edit
I have made a simple app which does what you want, the source code can be found here
Let me know if this is what you wanted.
也许您会找到 WPF 应用程序框架 (WAF) 的 BookLibrary 示例应用程序有用。它显示了 DataGrid 中的图书列表,并显示了一个向某人借书的模式对话框。该应用程序使用 MVVM 模式。
Maybe you find the BookLibrary sample application of the WPF Application Framework (WAF) useful. It shows a list of Books in a DataGrid and it shows a modal dialog to lend a book someone. The application uses the MVVM pattern.