Home > Mobile >  How to remove this line and change MouseOver for Background
How to remove this line and change MouseOver for Background

Time:10-07

I want to remove the ugly blue line, when mouse over is actived. How can I change the Hover-Background? I tried this one, but does not work

<Style TargetType="{x:Type ListViewItem}">
    <Setter Property="Background" Value="Transparent"/>
    <Setter Property="BorderBrush" Value="Transparent"/>
    <Style.Triggers>
         <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Background" Value="Red" />
         </Trigger>
    </Style.Triggers>

CodePudding user response:

You can set ListView's ItemContainerStyle for changing MouseOver background as :

<ListView x:Name="list">
        <ListView.ItemContainerStyle>
            <Style TargetType="ListViewItem">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ListBoxItem">
                        <Border Name="bdr"
                            Padding="2"
                            SnapsToDevicePixels="true">
                            <ContentPresenter />
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsSelected" Value="true">
                                <Setter TargetName="bdr" Property="Background" Value="LightBlue"/>
                            </Trigger>
                                <Trigger Property="IsMouseOver" Value="true">
                                    <Setter TargetName="bdr" Property="Background" Value="Red"/>
                                </Trigger>
                            </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            </Style>
        </ListView.ItemContainerStyle>
    </ListView>

Regards,

Nitin

  • Related