I prepared a WPF DataGrid and want to use a RadComboBox in a template column but the ItemsSource binding for MVVM does not work.
Is there any solution for that?
<DataGridTemplateColumn>
<DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<telerik:RadComboBox ItemsSource="{Binding DataContext.Grades}" />
</DataTemplate>
</DataGridTemplateColumn.CellEditingTemplate>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<telerik:RadComboBox ItemsSource="{Binding DataContext.Grades}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
If
Gradesis a collection property in your data grid items, removeDataContext.If you have Telerik controls anyway, why not use its data grid equivalent
RadGridViewdirectly? It will automatically use its ownRadComboBoxcontrol if you create a combo box column in it, e.g.:As a notice, you must have a property like
SelectedGradethat stores the selected combo box item in your item type, because if you do not set aDataMemberBinding, the column will not show anything.