You need to cast cast to a ComboBoxItem
.
var item = cbxCereais.SelectedValue as ComboBoxItem;
var text = item.Content.ToString();
This occurs because items in a ComboBox
are treated as ComboBoxItem
objects. Doing the cast as reported and accessing the Content
property solves the problem.
Finding the Name / Value Property
Complementing the answer after having understood what was requested after comments made.
To search for the "value" of a ComboBoxItem, we can use the Name property:
<ComboBox x:Name="cbxCereais" HorizontalAlignment="Left" Margin="145,178,0,0" VerticalAlignment="Top" Width="220">
<ComboBoxItem Content="Milho" Name="M" />
<ComboBoxItem Content="Soja" Name="S" />
<ComboBoxItem Content="Feijão" Name="F" />
</ComboBox>
And in the code:
var item = cbxCereais.SelectedValue as ComboBoxItem;
var text = item.Name;