scrollviewer 内的 Listview 防止 scrollviewer 滚动

Listview inside of scrollviewer prevents scrollviewer scroll(scrollviewer 内的 Listview 防止 scrollviewer 滚动)
本文介绍了scrollviewer 内的 Listview 防止 scrollviewer 滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个滚动查看器,里面有几个列表框.问题是如果用户在鼠标悬停在列表视图上时使用鼠标中键滚动滚动查看器.listview 将其内部的 scrollviewer 滚动到底部,然后继续捕获鼠标,从而阻止包含的 scrollviewer 滚动.

I have a scrollviewer with a couple listboxes in it. The problem is if a user uses the middle mouse roller to scroll the scrollviewer while their mouse is over a listview. The listview scrolls its internal scrollviewer to the bottom and then continues to capture the mouse, preventing the containing scrollviewer from scrolling.

关于如何处理这个问题的任何想法?

Any ideas on how to handle this?

推荐答案

这是因为 ListView 的(实际上是 ListBox 的)内容模板包装了它的项目ScrollViewer 本身.

That happens because the ListView's (ListBox's, actually) content template wraps its items with a ScrollViewer by itself.

最简单的方法是通过为内部 ListView 删除自己的 Template 来禁用它,它不会创建 ScrollViewer:

The simplest way is to disable it by dropping your own Template for the inside ListView, one that doesn't create a ScrollViewer:

    <ListView>
      <ListView.Template>
        <ControlTemplate>
          <ItemsPresenter></ItemsPresenter>
        </ControlTemplate>
      </ListView.Template>
      ...
    </ListView>

顺便说一句,如果您在 ListView 中有一个 ListView(这是我的情况),也会发生同样的情况.

BTW the same happens if you have a ListView inside a ListView (this was my case).

这篇关于scrollviewer 内的 Listview 防止 scrollviewer 滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)