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

问题描述

我现在有这一点,但它仅用于前景色工作。

任何帮助将apriciated:D

 < Style.Triggers>
    <触发属性=IsSelectedVALUE =真正的>
    < setter属性=前景VALUE =红/>
    < setter属性=背景值=绿色/>
    < /触发>
< /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

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

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

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>
解决方案

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的 - 我如何设置所选项目的背景颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 00:29