[英]Getting data grid combobox column value
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
. 使用dataTableComboBox_DropDownClosed
。 How can I get the current combobox value? 如何获得当前的组合框值?
Cast the sender object to ComboBox and then to ComboBoxItem. 将发件人对象转换为ComboBox,然后转换为ComboBoxItem。
private void dataTableComboBox_DropDownClosed(object sender, EventArgs e)
{
var SelectedValue = ((ComboBoxItem) ((ComboBox) sender).SelectedValue).Content;
}
Your SelectedValue variable will have the selected Item. 您的SelectedValue变量将具有选定的项目。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.