3
votes

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 that is taking precedence?

2
could you post the code/xaml in question? it would help us lots in helping you solve your problem! ;) - Ashley Grenon
I know, I know. There are many controls being created here and there. My question would have been very bulky. - tilish

2 Answers

1
votes

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.

0
votes

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

Background="Transparent"

Good luck!