I'm unable to get a combo to function as desired on a datagrid (using WPF).
A user should be able to select an item from a combo and the underlying database be updated when the user leaves the row. The combo should look like a combobox and not like a textbox.
Desired view to the user (using seed data):
The combo looks like a combo.
I could not get the underlying database updated so I posted this problem here and attempted what was suggested. However, now I get a flat combo appearance which won't allow for selecting another item AND the underlying database is still not being updated.
After suggestion:
The combo functionality is lost. Clicking on the cell does not allow for selecting another item.
Xaml (after suggestion):
<DataGridTemplateColumn Header="CPT Code" ><DataGridTemplateColumn.CellTemplate><DataTemplate><TextBlock Text="{Binding PartBBilling_CPT.PartBLookup_CPTCode}" /></DataTemplate></DataGridTemplateColumn.CellTemplate><DataGridTemplateColumn.CellEditingTemplate><DataTemplate><ComboBox ItemsSource="{Binding PartBCombo, RelativeSource={RelativeSource AncestorType=Window}}" DisplayMemberPath="PartBLookup_CPTCode" SelectedItem="{Binding PartBBilling_CPT, UpdateSourceTrigger=PropertyChanged}" SelectionChanged="PartBCPT_SelectionChanged" /></DataTemplate></DataGridTemplateColumn.CellEditingTemplate></DataGridTemplateColumn>
SelectionChanged suggestion:
Private Sub PartBCPT_SelectionChanged(sender As Object, e As SelectionChangedEventArgs) dgPartBBilling.CommitEdit(DataGridEditingUnit.Row, True) End Sub
What I would like is for the RowEditEnding event to fire to write the contents of the grid back to the database.
Thanks for any help or advice.
Thanks.