开发者

WPF: Help with Scrollviewer MouseWheel Behavior

For some reason my scrollviewer does not process the mousewheel events (or at least scroll when you mouse wheel) when the mouse is over any child. I want it so that either when the mouse wheel is over the entire scrollviewer area, mousewheel scrolls. Either that or when you click on something contained in the scroller, it processes mouse wheel no matter where the mouse is because it has focus. Is there any easy way to do this?

The basic layout tree goes like so in XAML:

<ScrollViewer x:Name="scroller">
    <StackPanel x:Name="stackPanel" Orientation="Vertical">
        <Expander>
            <WrapPanel />
 开发者_运维知识库       </Expander>
        <Expander>
            <WrapPanel />
        </Expander>

    </StackPanel>
</ScrollViewer>


I figured out the problem. I was actually using a custom WrapPanel that i created, and i forgot that control had its own scrollviewer (invisble since it was set to Auto size). So the wrappanel's scroller was stealing the mousewheel event from the outside scroller. I took out the scroller in the custom wrap panel and everything works normal now.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜