Silverlight: Handle mouse events in a control behind some other control

In Silverlight, if you put a control behind another control (for example using Canvas.ZIndex property), only the top control will get mouse events such as MouseMove, MouseEnter, MouseLeave, MouseLeftButtonDown and MouseLeftButtonUp.

This is somewhat counterintuitive, at least compared with other UI frameworks, where all controls is question get mouse events (except, may be, clicking).

If your top control is passive (for example, just a semi-transparent Rectangle), you can prohibit handling of input events by setting IsHitTestVisibile to false.

Leave a comment