Friday, February 1, 2013

Silverlight TextBlock Binding to SelectedItem in ComboBox

Silverlight TextBlock Binding to SelectedItem in ComboBox

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!

Answers & Comments...

Answer: 1

Assuming you called the ComboBox "ComboBox1" You could use-

<TextBlock Text="{Binding ElementName=ComboBox1,Path=SelectedItem.Title}"/> 
by : Jason Quinnhttp://stackoverflow.com/users/337226




No comments:

Post a Comment

Send us your comment related to the topic mentioned on the blog