In all of the examples of DataGridComboBoxColumn ItemSource comming from the Resources.
Couldn’t it be binding directly to a list in the CodeBehind ?
In all of the examples of DataGridComboBoxColumn ItemSource comming from the Resources. Couldn’t it
Share
It depends what you mean with binding directly to a list in the CodeBehind.
You can declare the column with…
and then in code-behind set the ItemsSource…
However you can not directly use the binding in XAML, something like:
because
DataGridComboBoxColumnis not a part of the visual tree.There are workarounds for this. The most simple is using a DataGridTemplateColumn and placing the ComboBoxes directly in the edit-DataTemplate. If you use a ViewModel, you can provide the data through it. Otherwise look here and here for workarounds.