问题
I have a ComboBox that is bound to a collection of CLR objects. Each item in the ComboBox is displayed via a DataTemplate. This DataTemplate contains an Image and a Title associated with the item. After a user clicks an item in the ComboBox, I want to display the selected items Title in another TextBlock in the screen.
My question is, how do I bind the Text property of the TextBlock to the Title property of the item selected in the comboBox?
Thank you!
回答1:
Assuming you called the ComboBox "ComboBox1" You could use-
<TextBlock Text="{Binding ElementName=ComboBox1,Path=SelectedItem.Title}"/>
来源:https://stackoverflow.com/questions/4493403/silverlight-textblock-binding-to-selecteditem-in-combobox