[英]TreeView shows blue for selected item
I have a treeview structure. 我有一个树视图结构。 When I try to click on the nodes there is a blue color that shows the node selected.
当我尝试单击节点时,会出现一种蓝色,显示所选节点。 How can I remove that.
我怎么能删除它。 I don't want a selection color to be displayed on the tree.
我不希望在树上显示选择颜色。
ItemContainerStyle
method does not work for me say on Windows-8. 在Windows-8上,
ItemContainerStyle
方法对我说不起作用。 There are 4 brushes that generally correspond to this and are used by the default Template for TreeViewItem
有4个画笔通常与此对应,并由
TreeViewItem
的默认模板使用
keys: 键:
HighlightBrushKey
- Background with focus. HighlightBrushKey
- 具有焦点的背景。
HighlightTextBrushKey
- Foreground with focus. HighlightTextBrushKey
- 具有焦点的前景。
InactiveSelectionHighlightBrushKey
- Background without focus. InactiveSelectionHighlightBrushKey
- 无焦点的背景。
InactiveSelectionHighlightTextBrushKey
- Foreground without focus. InactiveSelectionHighlightTextBrushKey
- 没有焦点的前景。
Just override them as you see fit, for your requirement something like this would do fine: 只要按照你认为合适的方式覆盖它们,对于你的要求,这样的事情会很好:
<TreeView>
<TreeView.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}"
Color="Transparent" />
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}"
Color="Black" />
<SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightBrushKey}"
Color="Transparent" />
<SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightTextBrushKey}"
Color="Black" />
</TreeView.Resources>
</TreeView>
Do pay attention to only overriding them within the scope you require. 请注意仅在您需要的范围内覆盖它们。 For example if you put all this into App.xaml you're going to see some weird side-effects as all control's using these Brushes would now end up using your overridden ones which may not be what you're after.
例如,如果你把所有这些都放到App.xaml中,你会看到一些奇怪的副作用,因为使用这些画笔的所有控件现在最终都会使用被覆盖的那些,这可能不是你想要的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.