tags:

views:

66

answers:

2

Hi. I have a UserControl in WPF. The UserControl has a MouseLeftMouseButtonUp event. The problem is- the Window has a this.DragMove() method in its MouseDown event which seems to interfere with the MouseLeftMouseButtonUp in the User Control (I need the this.DragMove() method to move the borderless window). Any ideas? Thanks!

A: 

DragMove is a synchronous call; it blocks until the user is done moving the window. This means once DragMove returns, the left button is up. Add your code immediately after your DragMove() call and you should be fine.

Ed Noepel
But the DragMove call is in the Window_MouseDown event, and the code I want to run is in the UserControl_MouseLeftButtonUp event. How do I add the code after the DragMove so that it will only run when I click on the userControl?
amitairos
When you click on the UserControl, you are initiating a MouseDown every time, even if you do not move the window. DragMove returns after the mouse button has been released (MouseUp). Does "only run when I click" really mean "only run when I do not move the window"? If so, you could store the window position before and after calling DragMove. If the window did not move, run your code.
Ed Noepel
Yes, but the MouseUp event doesn't get triggered at all.
amitairos
A: 

I had issues like this too and found that using click events instead of mousebutton events kept from firing dragmove. For my fix I just had to swap a label for a button. It's possible you could subclass a different element for your usercontrol so that you could pick up a click event to use?

TWood