Hello I'm using the WPF DataGrid and I'm trying to get the ComboBox Column to work.
<tk:DataGridComboBoxColumn Header="GroupLevel"
DisplayMemberPath="Type"
SelectedItemBinding="{Binding Path=GroupLevel}"
>
<tk:DataGridComboBoxColumn.EditingElementStyle>
<Style TargetType="ComboBox">
<Setter Property="ItemsSource" Value="{Binding Path=GroupLevel.Group.GroupLevels}" />
</Style>
</tk:DataGridComboBoxColumn.EditingElementStyle>
</tk:DataGridComboBoxColumn>
When I look at the grid, the column is blank, like its not using the display member path. But once I click in the column the combobox shows up and shows all the items in my ItemsSource and selects the proper one, so I know the bindings are all working correctly, even the DisplayMemberPath. Its just when I'm not editing the cell that it shows up blank.
Did I miss a property some where ?
Thanks, Raul
im pretty sure that this is because when you are not in edit mode your Column does not have an items source and a ComboBox cant have a selected item without an items source. as soon as you go to edit mode your column gets its items source and everything is cool. you can fix this by specifying an items source like so :-
<tk:DataGridComboBoxColumn.ElementStyle>
<Style TargetType="ComboBox">
<Setter Property="ItemsSource" Value="{Binding Path=GroupLevel.Group.GroupLevels}" />
</Style>
</tk:DataGridComboBoxColumn.ElementStyle>
then both your editing element and your (non-editing)element has the same ItemsSource
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With