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>
这篇关于将选定和未聚焦的列表框样式更改为不灰显的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:将选定和未聚焦的列表框样式更改为不灰显


- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- 如何用自己压缩一个 IEnumerable 2022-01-01
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- 输入按键事件处理程序 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- WebMatrix WebSecurity PasswordSalt 2022-01-01
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01