views:

3914

answers:

2

Hi, 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>
A: 

It is the Border sub-element of the ListViewItem named "Bd" which handles background painting.

<Setter TargetName="Bd" Value="Green" Property="Background" />
kek444
Then i get "TargetName property cannot be set on a Style Setter." error.
monkey_p
Move it to ControlTemplate.Triggers inside the Style.
kek444
+2  A: 

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>
Nir
Thanks this worked, I had to fix your xml a bit :D The </Style.Triggers> should be </Style>
monkey_p