I have set mouse events on a Canvas
as follows:
<Canvas MouseUp="CanvasUp" MouseDown="CanvasDown" MouseMove="CanvasMove"> ... </Canvas>
But these are active only on the child elements like Image
and Rectangle
, not on the empty space. How can I solve this?
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.
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
Set the background color. It defaults to null
.
Use Background="White"
for instance.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With