开发者

WPF: Canvas mouse events not firing on empty space

I have set mouse events on a Canvas as follows:

<Canvas MouseUp="CanvasUp" MouseDown=开发者_运维技巧"CanvasDown" MouseMove="CanvasMove">
...
</Canvas>

But these are active only on the child elements like Image and Rectangle, not on the empty space. How can I solve this?


A control with no background color set (explicitly or through styles etc) will default to having a background color of null - making it not hit-testable.

If you set the background to "Transparent" (or anything other than null ({x:Null})) then it will be able to pick up the mouse events


Set the background color. It defaults to null.

Use Background="White" for instance.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜