Reputation: 3651
I am trying to bind my combobox text/value to a label. I am able to bind a slider to the label but when I use the same method to bind a combobox, it shows no results. Please advice. Thanks.
<!--Works-->
<Slider Name="slider2" Width="144"/>
<Label Content="{Binding Value, ElementName=slider2}"/>
<!--Not working-->
<ComboBox Name="secondaryTable" Width="120">
<ComboBoxItem Content="A"/>
<ComboBoxItem Content="B"/>
<ComboBoxItem Content="C"/>
</ComboBox>
<Label Content="{Binding Value, ElementName=secondaryTable}"/>
Upvotes: 0
Views: 583
Reputation: 2716
You can bind to the SelectedValue property
<Label Content="{Binding SelectedValue.Content, ElementName=secondaryTable}"/>
Upvotes: 1
Reputation: 81243
You need to bind to SelectedItem.Content
property.
<Label Content="{Binding SelectedItem.Content, ElementName=secondaryTable}"/>
OR
Text
property of ComboBox.
<Label Content="{Binding Text, ElementName=secondaryTable}"/>
Upvotes: 1