-1

WPF Application

In datagrid,if I use DataGridComboBoxColumn to show Combobox,it is only show when I double click the cell enter edit status.

I want to show the combobox all the time, and don't need to double click the cell. How to do?

1 Answer 1

1

Replace the DataGridComboBoxColumn with a DataGridTemplateColumn and add a ComboBox to its CellTemplate and CellEditingTemplate:

<DataGridTemplateColumn>
    <DataGridTemplateColumn.CellTemplate>
        <DataTemplate>
            <ComboBox ItemsSource="..." />
        </DataTemplate>
    </DataGridTemplateColumn.CellTemplate>
    <DataGridTemplateColumn.CellEditingTemplate>
        <DataTemplate>
            <ComboBox ItemsSource="..." />
        </DataTemplate>
    </DataGridTemplateColumn.CellEditingTemplate>
</DataGridTemplateColumn>
1
  • Can you tell me how to updated the DataGrid when this combobox value is changed?
    – Batman
    Aug 23, 2021 at 11:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.