有一天,我发现我所有的WPF应用程序都无法将其拖动到窗口之外,并且无法使用实时预览来调整任何窗口的大小。
我的问题是为什么会发生这种情况,我该如何解决?
您可以查看下面显示的动画图像:
您会注意到,当我的光标在窗口之外时,调整大小会立即停止,并且当光标第一次离开窗口时,窗口会保持大小。如果光标重新进入窗口区域,则窗口大小调整将恢复。
我不仅编写了所有WPF应用程序,而且还复制了其他WPF应用程序:
非WPF应用程序的行为正确。
因为我的系统版本是Windows 10(1809),而现在我的系统版本是Windows 10(1903),所以几个月前就出现了这种现象。从.NET Framework 3.5 / 4.5 / 4.8和.NET Core 3.0嵌入的WPF应用程序。
Update1:我刚刚清理了所有驱动器,并使用一些核心应用程序重新安装了Windows 10 Professional(1903,客户版本),该问题仍然存在。核心应用程序是Chrome,PalmInput IME和iTunes。
Update2:我已经编写了一个WPF应用程序来处理窗口消息。我发现49757当我调整其外部窗口的大小时,该消息将停止接收。该消息在我朋友的系统上正常运行。
更新:
\n\n正如WPF 团队成员所指出的,在 WPF 中禁用手写笔和触摸支持的推荐方法是使用如下Switch.System.Windows.Input.Stylus.DisableStylusAndTouchSupport设置:App.config
<?xml version="1.0" encoding="utf-8" ?>\n<configuration>\n <runtime>\n <AppContextSwitchOverrides value="Switch.System.Windows.Input.Stylus.DisableStylusAndTouchSupport=true" />\n </runtime> \n</configuration>\nRun Code Online (Sandbox Code Playgroud)\n\n另请注意,这不是一个解决方案,而是一种解决方案,可能并不适合所有场景。
\n\n原来的:
\n\nMarkus Eisenst\xc3\xb6ck找到了解决此问题的方法。通过在 WPF 中禁用平板电脑支持,您将体验到预期的行为。我已经测试过,它可以在我的机器上运行(Windows 10 版本 1903 和 .NET Framework 4.6.2):
\n\npublic static void DisableWpfTabletSupport()\n{\n // Get a collection of the tablet devices for this window. \n TabletDeviceCollection devices = System.Windows.Input.Tablet.TabletDevices;\n\n\n if (devices.Count > 0)\n {\n // Get the Type of InputManager. \n Type inputManagerType = typeof(System.Windows.Input.InputManager);\n\n\n // Call the StylusLogic method on the InputManager.Current instance. \n object stylusLogic = inputManagerType.InvokeMember("StylusLogic",\n BindingFlags.GetProperty | BindingFlags.Instance | \n BindingFlags.NonPublic,\n null, InputManager.Current, null);\n\n\n if (stylusLogic != null)\n {\n // Get the type of the stylusLogic returned \n // from the call to StylusLogic. \n Type stylusLogicType = stylusLogic.GetType();\n\n\n // Loop until there are no more devices to remove. \n while (devices.Count > 0)\n {\n // Remove the first tablet device in the devices collection. \n stylusLogicType.InvokeMember("OnTabletRemoved",\n BindingFlags.InvokeMethod | \n BindingFlags.Instance | BindingFlags.NonPublic,\n null, stylusLogic, new object[] { (uint)0 });\n }\n }\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n
| 归档时间: |
|
| 查看次数: |
287 次 |
| 最近记录: |