Get selected value from combo box in C# WPF

后端 未结 21 679
粉色の甜心
粉色の甜心 2020-12-08 09:29

I have just started using WPF forms instead of Windows Forms forms. In a Windows Forms form I could just do:

ComboBox.SelectedValue.toString();
21条回答
  •  我在风中等你
    2020-12-08 10:00

    Ensure you have set the name for your ComboBox in your XAML file:

    
    

    In your code you can access selected item using SelectedItem property:

    MessageBox.Show(comboBox.SelectedItem.ToString());
    

提交回复
热议问题