Note that there are some explanatory texts on larger screens.

plurals
  1. PODataGrid and Cell-Level ComboBoxes
    primarykey
    data
    text
    <h2>Scenario</h2> <p>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.</p> <p>Common Road Blocks:</p> <ol> <li>The User must be able to add new rows (This Requires a ItemsSource item type that has a parameterless constructor).</li> <li>To access the database to populate the List of Available Options for the Comboboxes, the current project would require the Database Credentials/DataContext be passed into the Constructor.</li> </ol> <h2>Attempt 1</h2> <p>I've tried using 3 CollectionViewSources, one for each of the ComboBoxes (<a href="http://bea.stollnitz.com/blog/?p=387" rel="nofollow noreferrer">Concept Code Here</a>), 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. </p> <p>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. </p> <p>I also tried not sharing the CollectionViewSource as seen in <a href="https://stackoverflow.com/questions/5159893/binding-with-collectionviewsource">this question</a>, 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.</p> <h2>Attempt 2</h2> <p>I've looked at this question: <a href="https://stackoverflow.com/questions/3843617/how-to-get-cell-level-combobox-for-wpf-datagrid">How to get cell level ComboBox for WPF DataGrid?</a> </p> <p>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.</p> <h2>The Question</h2> <p>How do I do this correctly?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload