WPF:Canvas事件不工作 [英] WPF: Canvas Events Not working

查看:520
本文介绍了WPF:Canvas事件不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在画布上设置了鼠标事件,如下所示

I have set Mouse Events on a canvas as follows

 MouseUp="CanvasUp" MouseDown="CanvasDown" MouseMove="CanvasMove"

但是这些仅在像图像和矩形等子元素上有效,空间。
请告诉我如何解决

But these are active only on the child elements like Images and Rectangles, but not on the empty space. Please tell me how to solve

感谢

推荐答案

没有背景颜色设置的控件(显式或通过样式等)默认为背景颜色为null - 使其不可命中测试。

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.

背景为透明(或任何非null( {x:Null} )),那么它将能够拾取鼠标事件

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

这篇关于WPF:Canvas事件不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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