3

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?

Dave Clemmer
  • 3,741
  • 12
  • 49
  • 72
tilish
  • 1,093
  • 1
  • 9
  • 20

2 Answers2

1

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.

Dave Clemmer
  • 3,741
  • 12
  • 49
  • 72
tilish
  • 1,093
  • 1
  • 9
  • 20
0

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

Background="Transparent"

Good luck!

Dave Clemmer
  • 3,741
  • 12
  • 49
  • 72
Homam
  • 23,263
  • 32
  • 111
  • 187
  • I tried for the Canvas only - but just for the record do we have any explanation as to why setting a backgrounds to transparent might help? EDIT: (It would be useful to know) – tilish Oct 20 '10 at 10:46