鼠标滚轮在 ScrollViewer 的子控件上方时不起作用
我希望 ScrollViewer 的子控件能够自动将 MouseWheel 事件传递给 ScrollViewer,但事实并非如此。
我有一个带有列表框的 ScrollViewer。 如果我手动将 ListBox 的宽度调整为小于 ScrollViewer,MouseWheel 将在所有 ScrollViewer 上工作,但当鼠标位于 ListBox 上方时不起作用。
执行此操作的标准方法是什么? 我是否在 ListBox 上放置一个事件触发器来在父级上触发事件? 我是否在后面的代码中处理并重新路由该事件?
I was kind of expecting my ScrollViewer's child controls to hand the MouseWheel events back up the the ScrollViewer automatically, and that's not the case.
I have a ScrollViewer with a ListBox in it. If I manually resize the width of the ListBox to be less than the ScrollViewer, the MouseWheel works on all of the ScrollViewer but has no effect when the mouse is positioned above the ListBox.
What's the standard way to do this? Do I put an event trigger on the ListBox that fires the event on the parent? Do I handle and reroute the event in the code behind?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ListBox
的模板中有一个ScrollViewer
,因此ScrollViewer
将处理事件并阻止它们在可视化树中传播。您到底想通过在
ScrollViewer
中放置ListBox
来实现什么目的? 也许您需要重新模板化ListBox
,但如果没有进一步的信息就无法确定。The
ListBox
's template has aScrollViewer
in it, so thatScrollViewer
will be handling the events and stopping them from propagating up the visual tree.What exactly are you trying to achieve by having a
ListBox
inside aScrollViewer
? Perhaps you need to re-template theListBox
, but it's impossible to say without further info.