开发者

How can I make my ScrollViewer pass Click events through to the control behind it?

I have two grids overlaying one another, and the top layer is in a ScrollViewer.开发者_开发问答 The problem is the bottom layer has click events, and they don't get triggered with the ScrollViewer there.

Is there a way to have the ScrollViewer pass click events to the control behind it?

<Grid>
    <local:MyBackgroundControlWithClickEvents />
    <ScrollViewer>
        <local:MyForegroundControlWithClickEvents />
    </ScrollViewer>
</Grid>


Click events bubble up the visual tree to the root, because your control is not a parent of the ScrollViewer, it will not receive these events. I know they might overlap on screen, but as far as the visual tree is concerned they are siblings, not parent / child.

To make this work, you could change MyBackgroundControlWithClickEvents into a ContentControl and host the ScrollViewer within it.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜