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

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

问题描述

我创造一个数的ListView选择被一排(类似于iTunes的浏览器)做了一个WPF应用程序。问题是,默认非活动选择颜色太浅。 (见下文)

我怎样才能改变这种颜色,使我处于非活动状态的列表视图看起来像这样? (见下文)

解决方案

覆盖使用默认的SystemColor一个风格像这样:

 <风格的TargetType =ListViewItem的>
    < Style.Resources>
        <的SolidColorBrush X:键={X:静态SystemColors.ControlBrushKey}颜色={X:静态SystemColors.HighlightColor}/>
    < /Style.Resources>
< /样式和GT;


解决方案

的ListBox 模板使用系统颜色称为 ControlBrush 设置非活动高亮颜色。因此,你可以覆盖该颜色:

 <&ListBox中的GT;
    < ListBox.Resources>
        <的SolidColorBrush X:键={X:静态SystemColors.ControlBrushKey}>红色和LT; /&的SolidColorBrush GT;
    < /ListBox.Resources>
< /列表框>

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)

Solution

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>

解决方案

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天全站免登陆