WPF Listbox with touch inertia pulls down entire window(具有触摸惯性的WPF列表框拉下整个窗口)
问题描述
我有一个为触摸显示器构建的全屏 WPF 应用程序,并且我在主屏幕上有一些 Listbox
.
I have a full screen WPF application built for a touch monitor, and I have some Listbox
s on the main screen.
当我轻弹列表框"时,它滚动正常,但是当它到达列表末尾时,整个应用程序从屏幕顶部拉下,我可以停止这种行为吗不知何故?
When I flick the 'Listbox' it scrolls fine, but when it gets to the end of the list, the entire application gets pulled down from the top of the screen, can I stop this behavior somehow?
还有其他人看过吗?
推荐答案
是的,ListBox 的默认行为(或者更确切地说,默认 ListBox 模板中的 ScrollViewer)是奇怪 - 当我第一次看到它,我想这一定是一个恶作剧.事实上,很难找到任何关于它的文档 - 但它被简要提及 这里:
Yes, that default behaviour of the ListBox (or rather, the ScrollViewer inside the default ListBox template) is weird - when I first came across it, I thought it must be a practical joke. In fact, it's really hard to find any documentation about it - but it is briefly mentioned here:
ManipulationBoundaryFeedback 事件使应用程序或组件能够在对象碰到边界时提供视觉反馈.例如,Window 类处理 ManipulationBoundaryFeedback 事件以使窗口在遇到其边缘时略微移动.
The ManipulationBoundaryFeedback event enables applications or components to provide visual feedback when an object hits a boundary. For example, the Window class handles the ManipulationBoundaryFeedback event to cause the window to slightly move when its edge is encountered.
因此,一种解决方法是处理 ListBox 上的 ManipulationBoundaryFeedback,并将 Handled 设置为 true:
So, a way around it is to handle ManipulationBoundaryFeedback on the ListBox, and set Handled to true:
<ListBox ManipulationBoundaryFeedback="OnManipulationBoundaryFeedback">
// ...
</ListBox>
代码隐藏:
private void OnManipulationBoundaryFeedback(object sender, ManipulationBoundaryFeedbackEventArgs e)
{
e.Handled = true;
}
这篇关于具有触摸惯性的WPF列表框拉下整个窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:具有触摸惯性的WPF列表框拉下整个窗口


基础教程推荐
- SSE 浮点算术是否可重现? 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- c# Math.Sqrt 实现 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01