开发者

How to click an object with Panel.ZIndex low than another in wpf?

In wpf, i have to click on an image with Panel.ZIndex="1", but this image is "under" another image with a Panel.ZIndex="2". The event MouseDown fail. How to do that?

Thanks in advance, M.

<Grid >
    <Image Name="Image_开发者_C百科1" 
           Panel.ZIndex="1" />

    <Image Name="Image_2" 
           Panel.ZIndex="2" />

</Grid>


Try using IsHitTestVisible

<Grid >
   <Image Name="Image_1" 
          Panel.ZIndex="1" />

    <Image Name="Image_2" IsHitTestVisible="false" 
          Panel.ZIndex="2" />
</Grid>


You can have a transparent image on top of all others, and have the click-event on that.


The only way is to handle click on the Image_2 and programmatically click on Image_1. You can't break the layout.

Or, of cource, change ZIndex property.


I wonder why isn't mouse event working? WPF has tunneling model for events, so you must have the ability to catch a mouse event on any element if another doesn't block it using e.Handled = true...

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜