Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing mouse events to overlapped controls

My WPF user control consists of a few subcomponents, placed in such way that they overlap each other (sometimes completely), however they are on the same level on the visual tree (each subcomponent's parent is the main grid). I wish to pass mouse events from the topmost to the bottommost one, however default WPF's behavior passes them through the visual tree paths, not by their Z-order. Unfortunately, it is not possible to embed one in another (to take advantage of the default mechanisms). How may I resolve this problem?

Best regards -- Spook.

like image 565
Spook Avatar asked Oct 28 '25 06:10

Spook


1 Answers

A straightforward solution would be to handle all events in your parent Grid by not attaching any handlers in the child controls and manually "route" the events based on child z-order to the grid's children.

It will require lots of manual work, but I can't seem to find any other way to implement custom routing strategies in WPF.

like image 162
Jon Avatar answered Oct 30 '25 10:10

Jon