鼠标滚轮没有结束的ScrollViewer的子控件,当工作鼠标、控件、滚轮、结束

2023-09-04 08:44:33 作者:你美你先,我丑我靠边

我期待我的ScrollViewer的子控件自动手里的鼠标滚轮事件备份的ScrollViewer的,而事实并非如此。

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.

我有一个ScrollViewer中,在这一个列表框。如果我手动调整列表框的宽度小于ScrollViewer中,鼠标滚轮适用于所有的ScrollViewer,但没有当鼠标放置在列表框上面的效果。

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.

什么是标准的方法来做到这一点?难道我把一个事件触发器将触发父事件的列表框?难道我处理和重新路由在后面的code事件?

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?

推荐答案

列表框的模板有一个的ScrollViewer 在里面,使的ScrollViewer 将被处理的事件和传播了可视树阻止他们。

The ListBox's template has a ScrollViewer in it, so that ScrollViewer will be handling the events and stopping them from propagating up the visual tree.

究竟是什么你想实现由具有列表框的ScrollViewer ?也许你需要重新模板的列表框,但它是不可能的,没有进一步的信息说。

What exactly are you trying to achieve by having a ListBox inside a ScrollViewer? Perhaps you need to re-template the ListBox, but it's impossible to say without further info.