Solved it. Turns out Control Template handles the background property and the highlght color of the ListViewItem and not the ListViewItem itself.
WPF listviewItem styling trigger not working
-
30-06-2022 - |
Question
<ListView ScrollViewer.VerticalScrollBarVisibility="Disabled" Grid.Column="1" Grid.Row="3" ItemsSource="{Binding TeamTagsLiveDTO}" x:Name="teamTagsGrid" HorizontalAlignment="Left" SelectionChanged="SortByPlayerTags" Style="{StaticResource TeamTagsListViewStyle}">
<ListView.ItemContainerStyle>
<Style TargetType="{x:Type ListViewItem}">
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="BorderBrush" Value="{x:Null}"/>
<Style.Triggers>
<Trigger Property="IsSelected" Value="true">
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Background" Value="Black"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="BorderBrush" Value="{x:Null}"/>
</Trigger>
</Style.Triggers>
</Style>
</ListView.ItemContainerStyle>
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemTemplate>
<DataTemplate>
<TextBlock Style="{StaticResource teamtagsstyleLive}" Text="{Binding TeamTagsName1}" HorizontalAlignment="Left" VerticalAlignment="Top"/>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
i have this piece code as shown above:
The setter elements are working fine but the triggers are not working. Whats wrong here?
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow