Boardy Boardy - 3 months ago 27
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:

ComboBox.SelectedValue.toString();


and this would work fine.

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

Thanks

Answer

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();
Comments