Get Selected TreeViewItem Using MVVM

后端 未结 5 685
挽巷
挽巷 2020-12-08 11:26

So someone suggested using a WPF TreeView, and I thought: \"Yeah, that seems like the right approach.\" Now, hours and hours later, I simply can\'t believe how

5条回答
  •  天命终不由人
    2020-12-08 11:55

    Somewhat late to the party but for those who are coming across this now, my solution was:

    1. Add a reference to 'System.Windows.Interactivity'
    2. Add the following code into your treeview element.

    This will allow you to use a standard MVVM ICommand binding to access the SelectedItem without having to use code behind or some long winded work around.

提交回复
热议问题