Listview inside of scrollviewer prevents scrollviewer scroll(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 滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:scrollviewer 内的 Listview 防止 scrollviewer 滚动


- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- 如何用自己压缩一个 IEnumerable 2022-01-01
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
- WebMatrix WebSecurity PasswordSalt 2022-01-01
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- 输入按键事件处理程序 2022-01-01