mehmet6parmak
mehmet6parmak

Reputation: 4857

How to disable ListView's Hover and Tile effects?

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

Upvotes: 7

Views: 7254

Answers (2)

Hanzalah Adalan
Hanzalah Adalan

Reputation: 133

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/

Upvotes: 7

Filip Skakun
Filip Skakun

Reputation: 31724

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.

Upvotes: 4

Related Questions