禁用WPF TreeView(或TreeViewItem)选择? [英] Disable WPF TreeView (or TreeViewItem) selection?
问题描述
是否有一种好方法(除了重新模版整个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.
这篇关于禁用WPF TreeView(或TreeViewItem)选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!