应用程序似乎已冻结,因为在从用户代码调用DragMove()
之后,鼠标捕获不会从窗口调整大小或操作中自动释放。Dispatcher.PushFrame()
解决方法是在调用之前从应用程序中捕获鼠标的任何窗口手动释放鼠标捕获Dispatcher.PushFrame()
:
...
if (priority < DispatcherPriority.Loaded)
{
IntPtr capturingHandle = GetCapture();
for (int i = 0; i < Application.Current.Windows.Count; i++)
{
if (new WindowInteropHelper(
Application.Current.Windows[i]
).Handle == capturingHandle)
{
Mouse.Capture(
Application.Current.Windows[i],
CaptureMode.Element
);
Application.Current.Windows[i].ReleaseMouseCapture();
break;
}
}
}
...
此解决方法使用GetCapture()
p/invoke 声明:
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr GetCapture();