I've got the following code and I'm trying to get the selected combobox value:
<DataGridTemplateColumn x:Name="StatusCombo" Header="Change Status">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ComboBox x:Name="sslStatusTableCombo" Canvas.Left="307" Canvas.Top="59"
Width="120" SelectedIndex="0"
DropDownClosed="dataTableComboBox_DropDownClosed" SelectedItem="0">
<ComboBoxItem Content="status1"/>
<ComboBoxItem Content="status2"/>
<ComboBoxItem Content="status3Approval"/>
<ComboBoxItem Content="status4"/>
</ComboBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
With a dataTableComboBox_DropDownClosed
. How can I get the current combobox value?
Cast the sender object to ComboBox and then to ComboBoxItem.
private void dataTableComboBox_DropDownClosed(object sender, EventArgs e)
{
var SelectedValue = ((ComboBoxItem) ((ComboBox) sender).SelectedValue).Content;
}
Your SelectedValue variable will have the selected Item.