具有触摸惯性的WPF列表框将下拉整个窗口 [英] WPF Listbox with touch inertia pulls down entire window

查看:189
本文介绍了具有触摸惯性的WPF列表框将下拉整个窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用于触摸显示器的全屏WPF应用程序,并且在主屏幕上有一些Listbox.

I have a full screen WPF application built for a touch monitor, and I have some Listboxs 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列表框将下拉整个窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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