WPF binding to Listbox selectedItem

前端 未结 5 1339
再見小時候
再見小時候 2020-12-13 18:19

Can anyone help with the following - been playing about with this but can\'t for the life of me get it to work.

I\'ve got a view model which contains the following p

5条回答
  •  独厮守ぢ
    2020-12-13 18:34

    since you set your itemsource to your collection, your textbox is tied to each individual item in that collection. the selected item property is useful in this scenario if you were trying to do a master-detail form, having 2 listboxes. you would bind the second listbox's itemsource to the child collection of rules. in otherwords the selected item alerts outside controls that your source has changed, internal controls(those inside your datatemplate already are aware of the change.

    and to answer your question yes in most circumstances setting the itemsource is the same as setting the datacontext of the control.

提交回复
热议问题