Change selected and unfocused Listbox style to not be grayed out(将选定和未聚焦的列表框样式更改为不灰显)
问题描述
我有一个非常简单的 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>
这篇关于将选定和未聚焦的列表框样式更改为不灰显的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:将选定和未聚焦的列表框样式更改为不灰显
基础教程推荐
- rabbitmq 的 REST API 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- c# Math.Sqrt 实现 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- 将 XML 转换为通用列表 2022-01-01