tags:

views:

486

answers:

2

Is it possible to set up a Grid or other container control to be sort of an event dam? So that when any events, specifically a left click, that start within it are working their way up that they stop at that control and go no further?

+1  A: 

You should be able to extend whatever control you want (assuming it is not sealed). In your extended class you can override the click event and swallow it (do not pass it to the base class).

Berkshire
+5  A: 

PreviewMouseDown is your friend...

Add this event to your control, and set the Handled property on true...

All events tunnel first from root to leaves in the preview fase, then they are handled from leaves to root in the actual event case...

So PreviewMouseDown handles the Grid before the Button, while the MouseDown event handles the Button before the Grid...

hope this helps...

Arcturus
Thanks Arcturus. Was actually in the process of figuring this out as you posted. This definitely helped and now everything is working as it should. :D
Totty
No problem :) Glad I could help! :D
Arcturus