scrollviewer内部的Listview阻止scrollviewer滚动 [英] Listview inside of scrollviewer prevents scrollviewer scroll
问题描述
我有一个带有几个列表框的滚动查看器.问题在于,如果用户在鼠标位于列表视图上方时使用鼠标中键滚动滚动查看器.列表视图将其内部的滚动查看器滚动到底部,然后继续捕获鼠标,从而阻止包含的滚动查看器滚动.
关于如何处理此问题的任何想法?
之所以会发生这种情况,是因为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屋!