To implement docking I was relying on listening to the Window.LocationChanged event to detect the changing position of a window being dragged around the screen. But a user reported that docking was not working on their machine.
Turns out they had disabled "Show window contents while dragging" in Windows performance options and as a result the LocationChanged event is only fired once the window is moved to it's final position, not while the window is in mid-flight.
I was wondering if there was an alternative way to detect window moves, a nice way. I know I could pinvoke, or wire up some horrific timer, but I was hoping for a better way, perhaps there is a reliable event to listen on?
Here's a method to forestall any "you didn't post any code"/"what have you tried" complaints.
protected override void OnLocationChanged(EventArgs e)
{
}
[Preview]MouseMove
does not fire when the mouse is over the non-client area, and as you have observed,LocationChanged
only fires while dragging if "show window contents while dragging" is toggled. You'll probably have to do some p/invoke or, alternatively, draw your own window chrome (but even that may not work if you callDragMove
to handle window dragging). Also, checking the mouse state doesn't cover all window movement--you can initiate and complete window relocation using only the keyboard.