Get wpf combobox selected value

后端 未结 5 981
无人及你
无人及你 2021-02-13 17:53

How do I get the selected value (eg Option1) as a string from my example below. I\'ve tried loads of suggestions on Google but can\'t get the string.

5条回答
  •  我在风中等你
    2021-02-13 18:38

    string Value="";
    if(myComboBox.SelectedIndex>=0) 
      Value=((ComboBoxItem)myComboBox.SelectedItem).Content.ToString();
    

提交回复
热议问题