Remove the mouse over effect on a ListView in WPF Remove the mouse over effect on a ListView in WPF wpf wpf

Remove the mouse over effect on a ListView in WPF


EDIT:

The only way I could get this to work was to redefine the ListViewItem ControlTemplate. Give the code below a try and see if it resolves your issue:

ListViewItem Style:

<Style x:Key="LvItemStyle" TargetType="ListViewItem"><Setter Property="Template">    <Setter.Value>        <ControlTemplate TargetType="ListViewItem">            <Border x:Name="border" Background="Transparent">                <VisualStateManager.VisualStateGroups>                    <VisualStateGroup x:Name="CommonStates">                        <VisualState x:Name="Normal" />                        <VisualState x:Name="Disabled" />                    </VisualStateGroup>                    <VisualStateGroup x:Name="SelectionStates">                        <VisualState x:Name="Unselected" />                        <VisualState x:Name="Selected">                            <Storyboard>                                <ColorAnimationUsingKeyFrames Storyboard.TargetName="border"                                                              Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)">                                    <EasingColorKeyFrame KeyTime="0" Value="LightBlue" />                                </ColorAnimationUsingKeyFrames>                            </Storyboard>                        </VisualState>                        <VisualState x:Name="SelectedUnfocused">                            <Storyboard>                                <ColorAnimationUsingKeyFrames Storyboard.TargetName="border"                                                              Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)">                                    <EasingColorKeyFrame KeyTime="0" Value="SkyBlue" />                                </ColorAnimationUsingKeyFrames>                            </Storyboard>                        </VisualState>                    </VisualStateGroup>                </VisualStateManager.VisualStateGroups>                <ContentPresenter/>            </Border>        </ControlTemplate>    </Setter.Value></Setter>

ListView:

    <Grid Background="DarkGray">    <ListView Grid.Row="1"          Margin="10"                            HorizontalContentAlignment="Stretch"          ItemsSource="{Binding MyItems}"          ItemTemplate="{StaticResource LvDataTemplate}"          ItemContainerStyle="{StaticResource LvItemStyle}"          ScrollViewer.CanContentScroll="False"          ScrollViewer.PanningMode="VerticalOnly"          ScrollViewer.PanningRatio="0.5">    </ListView></Grid>

I have hardcoded the colors for the Selected VisualStates for demonstration purposes. Ideally you would get these from a resource file.


For me it worked well, like this:

<ListView.ItemContainerStyle>  <Style TargetType="ListViewItem">    <Style.Triggers>      <Trigger Property="IsMouseOver" Value="True">        <Setter Property="Background" Value="Transparent" />        <Setter Property="BorderBrush" Value="Transparent" />        <Setter Property="BorderThickness" Value="0" />      </Trigger>    </Style.Triggers>  </Style></ListView.ItemContainerStyle>