I have a ComboBoxwith 3 ComboBoxItems each containing an image and text in a stack panel.
I want to bind the SelectedValue to the TextBlock text but can’t just bind to content as this returns the stack panel. How do I bind the SelectedValue to the child TextBlock control? I don’t need to notify anything else I just need the SelectedValue to return the string.
<ComboBox>
<ComboBoxItem>
<StackPanel Orientation="Horizontal">
<Image Source="ImagePath/Image.bmp"/>
<TextBlock Text="MyTextString"/>
</StackPanel>
</ComboBoxItem>
</ComboBox>
SelectedValue is actually property related to binding. in your case you are creating combobox items statically.
check this
http://msdn.microsoft.com/en-us/library/system.windows.controls.primitives.selector.selectedvaluepath.aspx
in your case you can add Tag property on ComboBoxItem
and access it in code