#740 – Set Background of Canvas to Transparent to Receive Touch Events
January 23, 2013 2 Comments
If you define one or more touch event handlers for a Canvas panel, without setting any other properties, you may not see any touch events for the canvas.
This happens because none of the controls inheriting from Panel will receive either touch or mouse events unless you specify a value for the panel’s Background property. So, to receive touch events for the Canvas, you can just set its Background property to Transparent.
<Canvas Name="canvMain" Background="Transparent" TouchDown="Canvas_TouchDown" TouchMove="Canvas_TouchMove" TouchUp="Canvas_TouchUp"> </Canvas>
Pingback: Dew Drop – January 23, 2013 (#1,485) | Alvin Ashcraft's Morning Dew
Thank you ! 🙂 this was driving me nuts… I couldn’t find why the touch events were correctly received when happening on any child of the canvas (a label for example), but not in the canvas itself.