I want to highlight the row when I select from my ListView but I cant get it to work. Can anyone look at what I have and tell me what I’m doing wrong? Another question is What about having a property in my ViewModel and setting the Background color based on the bool value, how can that be achieve?
<ListView.ItemContainerStyle>
<Style TargetType="{x:Type ListViewItem}">
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="Green" />
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="Yellow" />
</Trigger>
</Style.Triggers>
</Style>
</ListView.ItemContainerStyle>
The problem here is the item template for the
ListViewautomatically adds the “Selected highlight” of brush typeSystemColors.HighlightBrushKey– the “true solution” would be to override the item template definition, but one way you can get what you’re after here is something like this: