WPF 中用于绑定的嵌套列表的建议方法

发布于 2024-08-11 09:58:51 字数 431 浏览 3 评论 0原文

问题:执行嵌套列表的最有效方法是什么,该列表允许在视图中进行数据绑定并了解选择了哪些装运,以便视图中的命令绑定可以在视图模型中的任何嵌套中的适当项目上运行清单?


信息:

我有一个程序,我花了很多时间来了解 WPF 和 MVVM。但现在我有点卡住了。这是一个库存计划。当货物进来时,人们会使用它来输入数据。一批货件包含一系列托盘,而托盘则包含一系列产品。

所以我想知道解决这个问题最明智的方法是什么?我考虑过让 allshipments 类有一个发货集合,shipment 类有一个托盘列表,而pallet 类有一个产品集合。但由于某种原因,我似乎无法通过该绑定来工作。我考虑的另一种方法是让我的所有货件类别都有货件、托盘和产品的列表,我的视图仅将相关托盘拉到感兴趣的货件,并将相关产品拉到感兴趣的托盘,但这并没有'看起来不像 MVVM,而且执行所有属性更改通知的后勤工作已经让我头晕目眩。

Question: What would be the most effective way of doing a nested list which allows for data binding in the view and awareness of what shipment is selected so that command bindings from the view can function in the viewmodel on the appropriate item in any of the nested lists?


Info:

I've got a program that I've been working a lot on to get an understanding of WPF and MVVM. But now I'm kind of stuck. It is an inventory program. People will use it when shipment come in to enter the data. A shipment has a collection of pallets, and pallets have collections of products.

So I was wondering what would be the most advisable way of going about this? I've considered having the allshipments class have a collection of shipments, the shipment class have a list of pallets, and the pallet class have a collection of products. But I can't seem to get the binding to work for through that for some reason. Another approach I've consider is having my all shipments class have a list of shipments, pallets, and products, and my view only pulls up associated pallets to the shipment of interest, and associated products to the pallet of interest, but that doesn't seem like MVVM, and and the logistics of doing all the property changed notification is already making my head spin.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

找回味觉 2024-08-18 09:58:51

一定要选择“allshipments 类有一个发货集合,该发货类有一个托盘列表,而托盘类有一个产品集合”。

关注此博客获取您的绑定工作

Definitely go with "the allshipments class have a collection of shipments, the shipment class have a list of pallets, and the pallet class have a collection of products".

Follow this blog to get your bindings working

东京女 2024-08-18 09:58:51

Rob Fonseca-Ensor 是对的,使用第一个变体。也许您应该使用 ObservableCollection 而不是 List 来使绑定起作用?

Rob Fonseca-Ensor is right, use the first variant. Maybe you should use ObservableCollection instead of List to make bindings work?

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