What is the simplest way to get the selected text of a combo box containing only text entries?

In your xml add SelectedValuePath="Content"

<ComboBox 
  Name="cboPickOne"
  SelectedValuePath="Content"
  >
  <ComboBoxItem>This</ComboBoxItem>
  <ComboBoxItem>should be</ComboBoxItem>
  <ComboBoxItem>easier!</ComboBoxItem>
</ComboBox>

This way when you use .SelectedValue.ToString() in the C# code it will just get the string value without all the extra junk:

   stringValue = cboPickOne.SelectedValue.ToString()

Leave a Comment