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

Getting selected value of a combobox

Try this: private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { ComboBox cmb = (ComboBox)sender; int selectedIndex = cmb.SelectedIndex; int selectedValue = (int)cmb.SelectedValue; ComboboxItem selectedCar = (ComboboxItem)cmb.SelectedItem; MessageBox.Show(String.Format(“Index: [{0}] CarName={1}; Value={2}”, selectedIndex, selectedCar.Text, selecteVal)); }

Difference between SelectedItem, SelectedValue and SelectedValuePath

Their names can be a bit confusing :). Here’s a summary: The SelectedItem property returns the entire object that your list is bound to. So say you’ve bound a list to a collection of Category objects (with each Category object having Name and ID properties). eg. ObservableCollection<Category>. The SelectedItem property will return you the currently … Read more