Question

I know there is a mouse click event for every control but is there a way to determine when the mouse click is not on the control?

Was it helpful?

Solution

you could use this code to find all controls or target type of visual element on the window and handle it's mouse events.

OTHER TIPS

you can check the IsMouseOver for false, and if you want to hook an action when the IsMouseOver == false, you can override the metadata of that dp.

You can call CaptureMouse and then that object will receive all mouse events. You can then determine from the point of the mouse down whether it was within the bounds of your control or not. Or you can listen for the LostMouseCapture event instead.

This won't work for the Click event (because there is no tunneling version, only a bubbling version), but you could handle the routed PreviewMouseLeftButtonDown on the Window class and check to see if the target control is in the hit tree.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top