为 WPF 触摸应用程序列表框添加惯性
Adding inertia for WPF touch application listbox
我有一个为触摸显示器构建的全屏 WPF 应用程序,我在主屏幕上有一些列表框。
当我轻弹 Listbox
时,它滚动得很好,但是当它到达列表的末尾时,整个应用程序从屏幕顶部被拉下来,但我需要惯性,因为列表框不适合整个 window。我怎样才能做到这一点?
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:
<ListBox ManipulationBoundaryFeedback="OnManipulationBoundaryFeedback">
// ...
</ListBox>
代码隐藏:
private void OnManipulationBoundaryFeedback(object sender, ManipulationBoundaryFeedbackEventArgs e)
{
e.Handled = true;
}
我有一个为触摸显示器构建的全屏 WPF 应用程序,我在主屏幕上有一些列表框。
当我轻弹 Listbox
时,它滚动得很好,但是当它到达列表的末尾时,整个应用程序从屏幕顶部被拉下来,但我需要惯性,因为列表框不适合整个 window。我怎样才能做到这一点?
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:
<ListBox ManipulationBoundaryFeedback="OnManipulationBoundaryFeedback">
// ...
</ListBox>
代码隐藏:
private void OnManipulationBoundaryFeedback(object sender, ManipulationBoundaryFeedbackEventArgs e)
{
e.Handled = true;
}