I need a control to call DragMove() for a Window on MouseLeftButton down, but still function when clicked.
If DragMove() is called, Click and MouseLeftButtonUp are not ever fired because DragMove() is a blocking call until they release the mouse button.
Does anyone know a workaround to make this work?
I have tried this hack based on Thread.Sleep which allows a click to work if it's quicker than 100 milliseconds, but it does not work reliably for users:
ThreadPool.QueueUserWorkItem(_ =>
{
Thread.Sleep(100);
Dispatcher.BeginInvoke((Action)
delegate
{
if (Mouse.LeftButton == MouseButtonState.Pressed)
{
window.DragMove();
}
});
});
EDIT: Well this hack worked...
window.DragMove();
RaiseEvent(new MouseButtonEventArgs(e.MouseDevice, e.Timestamp, MouseButton.Left)
{
RoutedEvent = MouseLeftButtonUpEvent
});
Anyone have a better one?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…