c# - ListBox 类似 ItemsControl 的触摸滚动

标签 c# wpf touch

WPF ListBox 内置了一些非常好的触摸滚动功能,我想在简单的 ItemsControl 上使用它。

我强烈喜欢使用现有的功能来实现这一点,因为我之前的努力(使用 TouchDown/Move/Up 事件)并不像 ListBox 的行为那么顺利,并且感觉不同到足以被识别在使用这两个控件的应用程序中。

我尝试在 reference source 中找到负责 ListBox 触摸行为的代码。 ,但 ListBox 类甚至不包含“Touch”一词。

有没有办法在 ItemsControl 上启用触摸滚动,或者,如果没有,负责隐藏 ListBox 的魔术代码在哪里以便我可以移植它?

最佳答案

ItemsControl 放入 ScrollViewer 中,并确保触摸事件从 ItemsControl< 内的任何控件向上冒泡到 ScrollViewer/

<ScrollViewer>
    <ItemsControl>
    </ItemsControl>
</ScrollViewer>

关于c# - ListBox 类似 ItemsControl 的触摸滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31700186/

相关文章:

wpf - WPF中超链接中的上标/下标

java - LibGDX 游戏 : Check if button is touched when touchDown is called

c# - 是否有与 StreamReader 的 Peek 方法等效的异步方法?

c# - DDD : Is it ok to generate/update my entities classes from changes in database schema?

c# - 如何保护将由移动应用程序和 Web 使用的 API

c# - 在键/鼠标事件后禁用 OxyPlot PlotView 最大/最小值

c# - 查询本地组

wpf - WPF MVVM中的键盘快捷键?

java - 不显示 MotionEvent.ACTION_UP 或 MotionEvent.ACTION_CANCEL

iPad 上的 iPhone 应用程序在首次启动时不响应触摸