Reputation: 1525
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?
Upvotes: 1
Views: 5921
Reputation: 14256
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.
Upvotes: 0
Reputation: 2814
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.
Upvotes: 0
Reputation: 14493
you could use this code to find all controls or target type of visual element on the window and handle it's mouse events.
Upvotes: 1
Reputation: 596
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.
Upvotes: 0