With a datagrid, I want to use a databound combobox to set the value of a property with the combobox's selected value. How would I go about doing that?
Cheers
With a datagrid, I want to use a databound combobox to set the value of a property with the combobox's selected value. How would I go about doing that?
Cheers
This can easily be achieved using the WPF DataGrid's CellTemplate features:
<DataGrid.Columns>
<DataGridTemplateColumn Header="My Column">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding MyBoundField}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
<DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<ComboBox ItemsSource="{Binding MyOptionsSource}" IsEditable="False"/>
</DataTemplate>
<DataGridTemplateColumn.CellEditingTemplate>
</DataGridTemplateColumn>
<DataGrid.Columns/>
Now just handle the ComboBox SelectionChanged event and force a Commit by giving the DataGrid keyboard focus :)
Have fun.