I'm new to WPF and I'm trying to figure out how to get the current text value of the selected item in a ComboBox. I saw in this question someone suggested doing MyComboBox.SelectedItem.Text
. However, SelectedItem
returns object
for me, so I only have options like ToString()
, Equals
, etc. What's going on? I'm using .NET 3.5, developing in VS 2010. The other methods I thought might be of use, like MyComboBox.SelectedValue
, also return object
. SelectedIndex
returns int
, but I want a string
value. MyComboBox
is of type ComboBox
. I'm accessing it in a method to handle the SelectionChanged event.
Each Item is a Object. The Displayed Data is Object.ToString (Item.ToString)
But you can Use any other Object member, Property or method from Object. You have added the object to Combo, then you know Object Type and can Cast it.