Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wpf ListView中的滑动问题_Wpf_Windows Runtime_Windows Store Apps_Winrt Xaml_Windows Store - Fatal编程技术网

Wpf ListView中的滑动问题

Wpf ListView中的滑动问题,wpf,windows-runtime,windows-store-apps,winrt-xaml,windows-store,Wpf,Windows Runtime,Windows Store Apps,Winrt Xaml,Windows Store,我正在Windows应用商店应用程序中使用ListView。 每当我开始在列表视图上滑动(使用模拟器点击模式)时,所有项目都会一起移动,如图所示。 如何禁用此操作事件?在您的列表视图中添加: ScrollViewer.VerticalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollMode="Disabled" 如果这还不够(这有时不适用于MouseWheel事件,因为这些事件仍然倾向于在ListView中捕获,而且如果Scr

我正在Windows应用商店应用程序中使用ListView。 每当我开始在列表视图上滑动(使用模拟器点击模式)时,所有项目都会一起移动,如图所示。
如何禁用此操作事件?

在您的
列表视图中添加:

ScrollViewer.VerticalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollMode="Disabled"
如果这还不够(这有时不适用于MouseWheel事件,因为这些事件仍然倾向于在ListView中捕获,而且如果ScrollViewer中的列表特别大,也会发生,我发现),那么您需要创建一个自定义控件来专门忽略该事件,例如,对于已更改的
指针

public class CustomListView : ListView
{
    protected override void OnApplyTemplate()
    {
        base.OnApplyTemplate();
        var sv = this.GetTemplateChild("ScrollViewer") as UIElement;
        if (sv != null)
            sv.AddHandler(UIElement.PointerWheelChangedEvent, new PointerEventHandler(OnPointerWheelChanged), true);
    }

    private void OnPointerWheelChanged(object sender, PointerRoutedEventArgs e)
    {
        e.Handled = false;
    }
}
这将禁用
列表视图中的鼠标滚轮滚动。您必须将对
列表视图的XAML引用从
更改为
,其中
名称空间
是您创建列表视图的名称空间