There is such a ListView:

<ListView x:Name="listView1" Width="300" HorizontalAlignment="Left" Background="White" BorderThickness ="0, 0, 2, 0" BorderBrush="#FFD3D7D8" DataContext="{Binding DataContext, ElementName=Window}" Foreground="Black" ItemsSource="{Binding ListViewAdapter}" MouseDoubleClick="listView1_MouseDoubleClick" SelectedIndex="0" SelectedItem="{Binding CurrentItem}" SelectionMode="Single" SelectionChanged="listView1_SelectionChanged" Padding="0" Style="{DynamicResource ListViewStyle1}"> <ListBox.ItemContainerStyle> // Вот от сюда <Style TargetType="{x:Type ListBoxItem}"> <Style.Triggers> <Trigger Property="IsSelected" Value="True"> <Setter Property="BorderThickness" Value="0, 1, 0, 1"/> <Setter Property="BorderBrush" Value="Yellow"/> <Setter Property="Background" Value="White"/> </Trigger> </Style.Triggers> </Style> </ListBox.ItemContainerStyle> // До сюда <ListView.ItemTemplate> <DataTemplate> <WrapPanel> <Image Width="40" Height="40" Source="{Binding Image}" /> <Border Height="45" BorderBrush="{x:Null}"> <TextBlock Margin="2,0" VerticalAlignment="Center" FontFamily="Tahoma" Text="{Binding Text1}" FontSize="14" /> </Border> <Border Height="45" BorderBrush="{x:Null}"> <TextBlock Margin="2,0" VerticalAlignment="Center" FontFamily="Tahoma" Foreground="#FF63676A" Text="{Binding Text2}" FontSize="14" /> </Border> </WrapPanel> </DataTemplate> </ListView.ItemTemplate> </ListView> 

From 16 to 26 lines I try to change the background of the item when it is selected on the form, but it remains the same blue (shown in the image below). What is wrong and why not working? I ask the help of experts! Thanks in advance. Here's how

  • Rewrite the entire style of the item (transfer all your ItemTemplate to ItemContainerStyle), wrap it in a border (or something like that, you have a WrapPanel (it may not stretch)), and change the color of this border through a trigger. Here's an example - tyk . Well, either put SolidColorBrush (as for me it is not a very good option). - EvgeniyZ
  • @EvgeniyZ Thanks for the answer, I'll go try. - Crypt0r

0