Hello,
I am using the WPF DataGrid with a DataGridTemplateColumn. The DataGridTemplateColumn.CellEditingTemplate contains a ComboBox with IsEditable set to 'true'. In my RowEditEnding event handler, I'd like to read the Text property of that ComboBox - the only problem is that I don't know how to retrieve the ComboBox instance within the event handler in order to get to the Text property.
For reference, here's my DataTemplate:
<!-- ... -->
<my:DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<ComboBox IsEditable="True" ItemsSource="{Binding Source={StaticResource ProductCategories}}" SelectedItem="{Binding Path=Name}" DisplayMemberPath="Name" />
</DataTemplate>
</my:DataGridTemplateColumn.CellEditingTemplate>
<!-- ... -->
And my code:
private void productsDataGrid_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e)
{
// UH-OH! Where do I find the ComboBox instance?
}
I know that I can get to the current affected row using e.Row... Maybe the solution involves something using e.Row? I've tried walking the visual tree recursively from e.Row down looking for an instance of ComboBox, but no dice. I'm almost positive that the solution is simple, however, I'm relativley new to WPF in general. Any suggestions would be much appreciated.
Thanks!