scrollviewer内部的Listview阻止scrollviewer滚动 [英] Listview inside of scrollviewer prevents scrollviewer scroll

查看:43
本文介绍了scrollviewer内部的Listview阻止scrollviewer滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

解决方案

之所以会发生这种情况,是因为ListView的内容模板(实际上是ListBox的内容模板)本身用ScrollViewer包裹了它的项目.

最简单的方法是通过在内部ListView中放置自己的Template来禁用它,这不会创建ScrollViewer:

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

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

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?

解决方案

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

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>

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

这篇关于scrollviewer内部的Listview阻止scrollviewer滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆