Silverlight TextBlock Binding to SelectedItem in ComboBox

谁都会走 提交于 2021-01-29 07:01:16

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!