禁用ListView中的垂直(滑动)滚动

时间:2022-03-12 19:47:30

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.

我正在UWP上开发一个主要针对W10移动用户的应用程序,但是我相信如果在触摸屏W10设备上尝试这个问题也是有效的。

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:

我使用ListView布局一组按钮(技术上是ListViewItems),它们有文本和图标。它们在我的SplitView中,与您在Windows默认应用程序(如Groove Music和News)中看到的方式类似,如图所示:

禁用ListView中的垂直(滑动)滚动

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.

它完全按照我希望的方式工作,除非用户用手指向上或向下拉ListView,它会向上或向下“压缩”列表 - 例如,一个有用的电子邮件列表动画,但不需要的东西我的程序的UI。

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?

有没有办法禁用这种行为?如果没有,是否有替代控制可以满足我的需要,或者我应该使用自定义控件?

1 个解决方案

#1


7  

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

在ListView上将ScrollViewer.VerticalScrollMode设置为Auto或Disabled:

<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.

默认值为Enabled,它将始终“挤压”顶部和底部。设置为“自动”时,如果不需要滚动(少于视口可以填充的元素),将禁用“压缩”效果。如果将值设置为Disabled,则无论需要显示多少元素,都将禁用滚动。

For the official documentation see here.

有关官方文档,请参见此处。

#1


7  

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

在ListView上将ScrollViewer.VerticalScrollMode设置为Auto或Disabled:

<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.

默认值为Enabled,它将始终“挤压”顶部和底部。设置为“自动”时,如果不需要滚动(少于视口可以填充的元素),将禁用“压缩”效果。如果将值设置为Disabled,则无论需要显示多少元素,都将禁用滚动。

For the official documentation see here.

有关官方文档,请参见此处。