禁用WPF TreeView(或TreeViewItem)选择?
是否有一种好方法(除了重新模版整个TreeViewItem.Template
之外)来禁用TreeView
中的选择?
Is there a nice way (except retemplating the whole TreeViewItem.Template
) to disable selection in TreeView
?
我基本上是在寻找TreeView
的ItemsControl
样式(ItemsControl
是在ListBox
上禁用"选择的最佳用途,请阅读此帖子)
I am basically looking for the ItemsControl
style of the TreeView
(An ItemsControl
is the best use to 'disable' selection on ListBox
, read this post)
每当项被选择,则可以 取消选择" 它.前任.从 http://www.codeproject.com/KB/WPF/TreeView_SelectionWPF.aspx修改代码或使用MVVM方法(请参见 http://www.codeproject.com/KB/WPF/TreeViewWithViewModel.aspx ),并始终将IsSelected设置回false.
Whenever an item is selected, you could "unselect" it. Ex. modify the code from http://www.codeproject.com/KB/WPF/TreeView_SelectionWPF.aspx or use a MVVM approach (see http://www.codeproject.com/KB/WPF/TreeViewWithViewModel.aspx) and always set IsSelected back to false.