将选定和未聚焦的列表框样式更改为不灰显

3

本文介绍了将选定和未聚焦的列表框样式更改为不灰显的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我有一个非常简单的 WPF 列表框,其中 SelectionMode 设置为 Multiple.

I have a really simple WPF ListBox with SelectionMode set to Multiple.

<ListBox SelectionMode="Multiple" />

当 ListBox 失去焦点时,很难判断选择了什么,因为选择的颜色会从蓝色变为浅灰色.更改此行为以使其保持蓝色的最简单方法是什么?

When the ListBox loses focus it's really hard to tell what's been selected because the selection colour changes from blue to a light grey colour. What's the easiest way of changing this behaviour so that it stays blue?

我知道这可能与 ListItem 的样式有关,但我找不到.

I know it's probably something to do with the ListItem's style, but I can't find where.

干杯.

类似:WPF ListView 非活动选择颜色

推荐答案

我在合并的 ResourceDictionary 中使用以下内容做了类似的事情,它可能会对您有所帮助:

I have done something like this using the following in a merged ResourceDictionary, it may help you:

<Style TargetType="ListBoxItem">
    <Style.Resources>
        <!--SelectedItem with focus-->
        <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="LightBlue" Opacity=".4"/>
        <!--SelectedItem without focus-->
        <SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightBrushKey }" Color="LightBlue" Opacity=".4"/>
    </Style.Resources>
</Style>

这篇关于将选定和未聚焦的列表框样式更改为不灰显的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

C# 中的多播委托奇怪行为?
Multicast delegate weird behavior in C#?(C# 中的多播委托奇怪行为?)...
2023-11-11 C#/.NET开发问题
6

如何将代表存储在列表中
How to store delegates in a List(如何将代表存储在列表中)...
2023-11-11 C#/.NET开发问题
6

代表如何工作(在后台)?
How delegates work (in the background)?(代表如何工作(在后台)?)...
2023-11-11 C#/.NET开发问题
5

Delegate.CreateDelegate() 和泛型:错误绑定到目标方法
Delegate.CreateDelegate() and generics: Error binding to target method(Delegate.CreateDelegate() 和泛型:错误绑定到目标方法)...
2023-11-11 C#/.NET开发问题
14

函数委托与函数
Func Delegate vs Function(函数委托与函数)...
2023-11-11 C#/.NET开发问题
6

具有未知类型的 CreateDelegate
CreateDelegate with unknown types(具有未知类型的 CreateDelegate)...
2023-11-11 C#/.NET开发问题
5