How to set <EventTrigger RoutedEvent="PreviewMouseMove">, correctly so that ListBoxItem changes color?

 <ListBox Grid.Column="0" ItemsSource="{Binding Category}" Background="#171717"> <ItemsControl.ItemTemplate> <DataTemplate> <ListBoxItem> <ListBoxItem.Content> <StackPanel Orientation="Horizontal"> <Image></Image> <TextBlock Text="{Binding Name}"></TextBlock> </StackPanel> </ListBoxItem.Content> </ListBoxItem> </DataTemplate> </ItemsControl.ItemTemplate> <ListBox.ItemContainerStyle> <Style TargetType="{x:Type ListBoxItem}"> <Setter Property="Background" Value="LightSteelBlue"/> <Setter Property="Padding" Value="5"/> <Style.Triggers> <Trigger Property="IsSelected" Value="True"> <Setter Property="Foreground" Value="White"/> <Setter Property="BorderThickness" Value="0"/> <Setter Property="Background" Value="Red"></Setter> </Trigger> <EventTrigger RoutedEvent="PreviewMouseMove"> <!--<Setter Property="Foreground" Value="Black"/> как реализовать такие сеттеры? <Setter Property="BorderThickness" Value="2"/> <Setter Property="Background" Value="Red"/>--> </EventTrigger> </Style.Triggers> </Style> </ListBox.ItemContainerStyle> </ListBox> 

    1 answer 1

     <EventTrigger RoutedEvent="PreviewMouseMove"> <BeginStoryboard> <Storyboard> <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(ListBoxItem.Background).(SolidColorBrush.Color)"> <EasingColorKeyFrame KeyTime="0" Value="Red" /> </ColorAnimationUsingKeyFrames> <ThicknessAnimationUsingKeyFrames Storyboard.TargetProperty="(ListBoxItem.BorderThickness)"> <EasingThicknessKeyFrame KeyTime="0" Value="2"/> </ThicknessAnimationUsingKeyFrames> </Storyboard> </BeginStoryboard> </EventTrigger> 

    When changing in the same way, the foreground is an error, so be careful)