Reputation: 6259
I try to change the Backgroundcolor of the selected ListBoxItem when it is not focused and the containing window is not active. The Window has ShowActivated = false.
But it is still grey.
Here is my code:
<ListBox x:Name="oList" >
<ListBox.ItemContainerStyle>
<Style TargetType="{x:Type ListBoxItem}">
<EventSetter Event="MouseDoubleClick"
Handler="listBoxItem_DoubleClick" />
<Style.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}"
Color="LightGreen" />
<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}"
Color="LightBlue" />
</Style.Resources>
</Style>
</ListBox.ItemContainerStyle>
<ListBoxItem Content="Coffie"></ListBoxItem>
<ListBoxItem Content="Tea"></ListBoxItem>
<ListBoxItem Content="Orange Juice"></ListBoxItem>
<ListBoxItem Content="Milk"></ListBoxItem>
<ListBoxItem Content="Iced Tea"></ListBoxItem>
<ListBoxItem Content="Mango Shake"></ListBoxItem>
</ListBox>
I hope someone can help me, what I am doing wrong.
Upvotes: 1
Views: 108
Reputation: 6304
Try adding this in your Style.Resources
(change color to your liking):
<SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightBrushKey}" Color="LightBlue"/>
Upvotes: 1