MouseDown不能在Grid中工作(仅在网格中的按钮上) [英] MouseDown doesnt work in Grid (only on buttons which in grids)

查看:164
本文介绍了MouseDown不能在Grid中工作(仅在网格中的按钮上)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到MouseDown事件的问题。我的应用程序看起来像这样,我的网格中添加了代码后面的按钮。

I have problem with MouseDown event. My app looks like that, I have grid in which im adding buttons in code behind

<Grid Grid.Column="1" Name="gridWithButtons" MouseDown="normalModeButtonsWP_MouseDown" >
        <WrapPanel Name="normalModeButtonsWP" MouseDown="normalModeButtonsWP_MouseDown" ></WrapPanel>
</Grid>

但是,当按下鼠标按钮在网格/ wrappanel(我的意思是在按钮之间的空白空间)它不起作用。仅当按下包装/网格中的按钮时才起作用。任何人都知道如何处理它?<​​/ p>

But when im pressing mouse button in grid/wrappanel ( i mean in empty space between buttons for example) it doesnt work. Works only when im pressing button which is in wrap/grid. Anyone know how to handle it?

推荐答案

单独设置IsHitTestVisible不会使其工作。

Setting IsHitTestVisible alone will not make it work.

如果将背景设置为无,则元素不可点击。为了使其可点击(适用于网格,堆栈面板等),将Background设置为#00000000。这更像是一种解决方法,但它工作并且看起来很好。

Elements are not clickable if Background is set to None. To make it clickable (applies to grid, stackpanel, etc) set the Background to #00000000. This is more like a workaround however it works and looks fine.

这篇关于MouseDown不能在Grid中工作(仅在网格中的按钮上)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆