我有一个非常简单的 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>
这篇关于将选定和未聚焦的列表框样式更改为不灰显的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!