Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disabling vertical (swipe) scrolling in a ListView

I am developing an application on the UWP primarily targeted to W10 mobile users, however I believe this issue will also be valid if attempted on a touchscreen W10 device.

I am using a ListView to lay out a set of buttons (ListViewItems, technically) which have text and an icon. They are in my SplitView and are used similar to how you see in the Windows default apps such as Groove Music and News, as pictured:

Example from Groove Music

It works perfectly as I'd hoped, except that if the user pulls up or down on the ListView with their finger it will 'squash' the list up or down - a useful animation for lists of emails, for example, but something undesirable on the UI of my program.

Is there a way of disabling this behaviour? If not, is there an alternative control that could suit my needs, or should I use a custom control?

like image 939
Ashley Davies Avatar asked Mar 15 '23 16:03

Ashley Davies


1 Answers

Set the ScrollViewer.VerticalScrollMode to Auto or Disabled on your ListView:

<ListView
    x:Name="ListView"
    ScrollViewer.VerticalScrollMode="Auto"
</ListView>

The default value is Enabled which will always "squash" the top and bottom. When set to Auto, then if there is no need to scroll (less elements than the viewport can fill), the "squash" effect will be disabled. And if you set the value to Disabled, then the scrolling will be disabled no matter how many elements need to be displayed.

For the official documentation see here.

like image 56
Kristian Vukusic Avatar answered Apr 01 '23 19:04

Kristian Vukusic