Boardy Boardy -4 years ago 151
C# Question

Get selected value from combo box in c# wpf

i think this might be a stupid question but I can't find it on the internet.

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


and this would work fine.

How do I do this in WPF it doesn't seem to have the option.


Answer Source

I have figured it out a bit of strange way of doing it compared to the old WF forms:

ComboBoxItem typeItem = (ComboBoxItem)cboType.SelectedItem;
string value = typeItem.Content.ToString();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download