Get wpf combobox selected value

后端 未结 5 1003
无人及你
无人及你 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:27

    You shouldn't insert the combobox items manually. Set them by using ItemsSource.

    Basically you should create a list of options (or objects representing options) and set them as ItemsSource, this way your SelectedItem will be exactly the option which is selected, not the automatically created wrapping ComboboxItem.

提交回复
热议问题