wpf中几种获取ComBox中值的方法
方法一:
string test = null;
foreach (ComboBoxItem item in e.AddedItems)
{
test = item.Content.ToString();
break;
}
方法二:
ComboBoxItem cbi = (ComboBoxItem)(sender as ComboBox).SelectedItem;
string selectedText = cbi.Content.ToString();
方法三:
ComboBoxItem cbi = (ComboBoxItem)combobox_Test.SelectedItem; //combobox_Test为combobox的name
string selectedText = cbi.Content.ToString();