How to disable ListView's Hover and Tile effects?
Asked Answered
S

2

6

I want to disable Tile effect that is some kind of pushed effect and hover background color effect of ListView control, how can i do that?

Thanks

Shaver answered 3/8, 2012 at 7:5 Comment(0)
U
4

Look at this question: Disable cross-slide selection for a listview

You can also make changes to the template to remove any visual states and adornments - go to the designer and right click your ListView/Edit Additional Templates/Edit Generated Item Container (ItemContainerStyle)/Edit a Copy... - that will extract the template you can modify using your preferred method.

Unbacked answered 3/8, 2012 at 7:57 Comment(3)
Sadly the extended style is no longer generated by Blend (it only generates the default), but it's available from the msdn msdn.microsoft.com/en-us/library/windows/apps/xaml/… .Polyhydroxy
Yes, I think the current ListViewItem template is very simplified - I suspect it's actually rendered at a platform/renderer level to improve performance and so if you want to customize it - you are actually complicating the template.Unbacked
yeah, sadly, I haven't figured out a better way of disabling all the item click animations while still retaining ScrollIntoView.Polyhydroxy
C
6

After some googling I found that the highlighting happens in the ListViewItemPresenter, which turns out to be pretty hidden. It's located inside the ControlTemplate of an ListViewItem, which is the ItemContainer for the ListView. The simplest way I've found to disable the effect is to simply override this ControlTemplate:

<ListView>
<ListView.ItemContainerStyle>
    <Style TargetType="ListViewItem">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate>
                    <ContentPresenter/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ListView.ItemContainerStyle>
<TextBlock Text="List Item" />
...
<TextBlock Text="List Item" />

source: https://blog.jonstodle.com/uwp-listview-without-highlighting-and-stuff/

Coincidence answered 18/6, 2016 at 12:41 Comment(1)
but please bear in mind this will break the accessibilty of the control..Coincidence
U
4

Look at this question: Disable cross-slide selection for a listview

You can also make changes to the template to remove any visual states and adornments - go to the designer and right click your ListView/Edit Additional Templates/Edit Generated Item Container (ItemContainerStyle)/Edit a Copy... - that will extract the template you can modify using your preferred method.

Unbacked answered 3/8, 2012 at 7:57 Comment(3)
Sadly the extended style is no longer generated by Blend (it only generates the default), but it's available from the msdn msdn.microsoft.com/en-us/library/windows/apps/xaml/… .Polyhydroxy
Yes, I think the current ListViewItem template is very simplified - I suspect it's actually rendered at a platform/renderer level to improve performance and so if you want to customize it - you are actually complicating the template.Unbacked
yeah, sadly, I haven't figured out a better way of disabling all the item click animations while still retaining ScrollIntoView.Polyhydroxy

© 2022 - 2024 — McMap. All rights reserved.