Maus-Ereignis nicht UIElement erreicht
-
09-10-2019 - |
Frage
ich einen 6x8 Raster von System.Windows.Controls.Canvas
Objekten. Die obere linke Leinwand erhält keine Mausereignisse während alle anderen tun. Ich habe versucht, OnMouseMove
und OnMouseClick
Ereignisse.
Ein Kind-Objekt ist der Umgang mit nicht das Ereignis, weil System.Windows.Media.VisualTreeHelper#GetChildrenCount()
zeigt keine Kinder. Ich konnte nicht PreviewOnMouseMove
entweder fangen. Kann es einige (vielleicht transparent) Kontrolle vor meiner Leinwand, die Vorrang nimmt?
Lösung 2
Finally found a solution. Each of the Canvas
es have Adorner
s. 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
.
Andere Tipps
I hope this helps you, Just set Transparent
value to the Background
property for the Canvas
:
Background="Transparent"
Good luck!