我有一个滚动查看器,里面有几个列表框.问题是如果用户在鼠标悬停在列表视图上时使用鼠标中键滚动滚动查看器.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 滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!