WPF ListView - 我如何设置所选项目的背景颜色? [英] WPF ListView - how do i set selected item background colour?

查看:24
本文介绍了WPF ListView - 我如何设置所选项目的背景颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前有这个,但它只适用于前景色.

I currently have this, but it only work for the foreground colour.

任何帮助都会得到帮助:D

Any help would be apriciated :D

<Style.Triggers>
    <Trigger Property="IsSelected" Value="true">
        <Setter Property="Foreground" Value="Red" />
        <Setter Property="Background" Value="Green"/> 
    </Trigger>
</Style.Triggers>

推荐答案

这会处理背景颜色,也许它也会帮助你找到前景的解决方案,这是来自 http://blogs.msdn.com/wpfsdk/archive/2007/08/31/specifying-the-selection-color-content-alignment-and-background-color-for-items-in-a-listbox.aspx

This will take care of the background color, maybe it will also help you find the solution for the foreground, this is from http://blogs.msdn.com/wpfsdk/archive/2007/08/31/specifying-the-selection-color-content-alignment-and-background-color-for-items-in-a-listbox.aspx

<Style TargetType="ListBoxItem">
    <Style.Resources>
        <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Green"/>
    </Style.Resources>
</Style>

这篇关于WPF ListView - 我如何设置所选项目的背景颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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