WPF ListView 非活动选择颜色 [英] WPF ListView Inactive Selection Color

查看:33
本文介绍了WPF ListView 非活动选择颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个 WPF 应用程序,其中连续进行了多个 ListView 选择(类似于 iTunes 浏览器).问题是默认的非活动选择颜色太浅.(见下文)

I'm creating a WPF application where several ListView selections are made in a row (similar to the iTunes browser). The problem is that the default inactive selection color is too light. (see below)

如何更改此颜色以使我的非活动列表视图看起来像这样?(见下文)

How can I change this color so my inactive listview looks like this? (see below)

使用 Style 覆盖默认的 SystemColor,如下所示:

Override the default SystemColor with a Style like so:

<Style TargetType="ListViewItem">
    <Style.Resources>
        <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="{x:Static SystemColors.HighlightColor}"/>
    </Style.Resources>
</Style>

推荐答案

ListBox 模板使用名为 ControlBrush 的系统颜色来设置非活动突出显示颜色.因此,您可以覆盖该颜色:

The ListBox template uses a system color called ControlBrush to set the inactive highlight color. Therefore, you can just override that color:

<ListBox>
    <ListBox.Resources>
        <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}">Red</SolidColorBrush>
    </ListBox.Resources>
</ListBox>

这篇关于WPF ListView 非活动选择颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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