Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF ListView - how do i set selected item background colour?

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>
like image 666
monkey_p Avatar asked Jul 20 '09 12:07

monkey_p


People also ask

How do I change the background color in WPF?

Navigate to the Properties window, and click the Background drop-down arrow, and choose Red or another color in the color picker.


1 Answers

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>
like image 72
Nir Avatar answered Sep 28 '22 20:09

Nir