如何在处理 selectionchanged 时获取 dataGrid 中组合框的选定项目

how to get selecteditem of combobox in dataGrid while selectionchanged is handling

我有一个这样的数据网格:

<datagrid itemssource="{Binding Path=ProdCommande, ElementName=CommandeWindow}" autogeneratecolumns="False">
        <DataGrid.Columns>
            <DataGridTextColumn x:Name="produitDateCommande" Binding="{Binding dateCommande}" Width="120" Header="Date Commande"/>   
            <DataGridTemplateColumn Header="Statut ">
                <DataGridTemplateColumn.CellTemplate>
                    <DataTemplate>
                        <ComboBox ItemsSource="{Binding StatutCommande, ElementName=CommandeWindow}" SelectedItem="{Binding SelectedStatut, Mode=TwoWay}" SelectionChanged="ComboBox_SelectionChanged" />
                    </DataTemplate>
                </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>
        </DataGrid.Columns>
</datagrid>

我只想在组合框帮助中获取所选项目!

确保将 sender 转换为 ComboBox

例如:

   private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
    var cb = sender as ComboBox;
    var item = cb.SelectedItem;
}

那么你应该能够将 SelectedItem 转换为它应该是的任何类型。