Reputation: 2866
ComboBox C depends on the selected value of ComboBox B, which depends on the selected value of ComboBox A. All of these ComboBoxes are in a DataGrid.
Common Road Blocks:
I've tried using 3 CollectionViewSources, one for each of the ComboBoxes (Concept Code Here), but the SelectedItem of the ComboBox gets automatically selected in the other DataGrid rows. I need to find a way to isolate the CollectionViewSource to each row.
I've considered just adding the CollectionViewSource data to each of the DataGrid Items so I can just bind to it that way, but I have to access the database to generate the CollectionViewSource.
I also tried not sharing the CollectionViewSource as seen in this question, but that destroyed the link between the 3 ComboBoxes, as well as the Rows. If I could just set the CollectionViewSources to be shared within each DataGrid Row and not between each of them, I think it would work. I just can't find a way to do that.
I've looked at this question: How to get cell level ComboBox for WPF DataGrid?
This would work, but the User needs to be able to add rows to the DataGrid. The example code in that question also uses a parameterless constructor. I am in a situation where access to the database to populate the lists would have to be passed into the constructor.
How do I do this correctly?
Upvotes: 0
Views: 340
Reputation: 132568
Bind to a List
or ObservableCollection
, not a CollectionViewSource
CollectionViewSource
tracks the Current Item, so changing the value in one ComboBox will change it in all ComboBoxes
Upvotes: 1