开发者

Mouse event not reaching UIElement

开发者 https://www.devze.com 2023-01-20 20:31 出处:网络
I have a 6x8 grid of System.Windows.Controls.Canvas objects. The top left canvas does not receive mouse events while all the others do. I tried OnMouseMove and OnMouseClick events.

I have a 6x8 grid of System.Windows.Controls.Canvas objects. The top left canvas does not receive mouse events while all the others do. I tried OnMouseMove and OnMouseClick events.

A child object isn't handling the event because System.Windows.Media.VisualTreeHelper#GetChildrenCount() doesn't show any children. I couldn't catch PreviewOnMouseMove either. Can there be some (perhaps transparent) control in front of my canvas tha开发者_高级运维t is taking precedence?


Finally found a solution. Each of the Canvases have Adorners. According to this MSDN article, adorners receive mouse events before the underlying UI element does. I set the IsHitTestVisible property of all my adorners to false.


I hope this helps you, Just set Transparent value to the Background property for the Canvas:

Background="Transparent"

Good luck!

0

精彩评论

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