TreeView 为所选项目显示蓝色 [英] TreeView shows blue for selected item

查看:25
本文介绍了TreeView 为所选项目显示蓝色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个树状结构.当我尝试单击节点时,会出现蓝色显示所选节点.我怎样才能删除它.我不想在树上显示选择颜色.

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 方法对我来说在 Windows-8 上不起作用.有 4 个画笔通常对应于此,并由 TreeViewItem

ItemContainerStyle method does not work for me say on Windows-8. There are 4 brushes that generally correspond to this and are used by the default Template for TreeViewItem

键:

HighlightBrushKey - 带焦点的背景.

HighlightTextBrushKey - 具有焦点的前景.

HighlightTextBrushKey - Foreground with focus.

InactiveSelectionHighlightBrushKey - 没有焦点的背景.

InactiveSelectionHighlightBrushKey - Background without focus.

InactiveSelectionHighlightTextBrushKey - 没有焦点的前景.

InactiveSelectionHighlightTextBrushKey - Foreground without focus.

只需按照您认为合适的方式覆盖它们,对于您的要求,这样的事情就可以了:

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>

请注意仅在您需要的范围内覆盖它们.例如,如果您将所有这些都放入 App.xaml 中,您将看到一些奇怪的副作用,因为使用这些画笔的所有控件现在最终会使用您覆盖的那些可能不是您所追求的.

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.

这篇关于TreeView 为所选项目显示蓝色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆