views:

69

answers:

2

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.

+2  A: 

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 to get your bindings working: http://bea.stollnitz.com/blog/?p=13

Rob Fonseca-Ensor
Thanks, this is working, I've only gotten down to the pallets so far, but i'm sure moving down from pallets to products won't be very hard. Thank ye.
Narcolapser
+2  A: 

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

levanovd
It's hilarious that you should say that, because that's where is started, turns out i need both an observable collection, and a collection view to expose the observable collection to get everything to work properly.
Narcolapser
Well if you're going to say i'm right, then i'll just have to give you 10 shiny points...
Rob Fonseca-Ensor