WPF binding to Listbox selectedItem

前端 未结 5 1442
再見小時候
再見小時候 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:51

    First off, you need to implement INotifyPropertyChanged interface in your view model and raise the PropertyChanged event in the setter of the Rule property. Otherwise no control that binds to the SelectedRule property will "know" when it has been changed.

    Then, your XAML

    
    

    is perfectly valid if this TextBlock is outside the ListBox's ItemTemplate and has the same DataContext as the ListBox.

提交回复
热议问题