3

I want to be able in my WPF application to detect the MouseUp event from anywhere. That is to say, if the user clicks in the control and holds his click, then releases it outside the Control, I want my MouseUp event to fire.

I have done the MouseDown event, it works, but the MouseUp event isn't fired if released outside the Window.

2 Answers 2

14

Add the CaptureMouse method in your MouseButtonDown handler

You can look up here on what it actually does.

1
  • 1
    You should call ReleaseMouseCapture on MouseButtonUp too
    – Skarllot
    May 22, 2020 at 16:16
0

Another way is using the windows API's for mouse_event described here: Simulating Mouse Clicks

I would use the CaptureMouse listed above first but if that doesn't work for you this one should.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.