WPF窗口偶发触摸不响应,但鼠标点击响应

weixin_38063619 2017-12-22 10:03:40
最近用WPF开发触摸屏软件,控件上的事件都是用mouse事件,正常的时候触摸是可以响应的,但是操作一会偶发会出现触摸不响应。但这个时候我用鼠标操作是可以的。(只是我写的这个WPF窗口不响应触摸,弹出个tastmgr,资源管理器是响应触摸的)求助  这是什么原因??
我搜到了一个跟我遇到应该是一样的问题,但没有解决方案  https://social.msdn.microsoft.com/Forums/vstudio/en-US/ac81b552-44ac-4410-a5cd-4dbf6132a634/wpf-apps-stop-responding-to-touches-while-mouse-continues-to-work?forum=wpf
...全文
14 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
weixin_38117590 2018-01-02
  • 打赏
  • 举报
回复
这段代码对我好像起作用,最近这个问题一直没有发生了public static void DisableWPFTabletSupport() { // Get a collection of the tablet devices for this window. TabletDeviceCollection devices = System.Windows.Input.Tablet.TabletDevices; if (devices.Count > 0) { // Get the Type of InputManager. Type inputManagerType = typeof(System.Windows.Input.InputManager); // Call the StylusLogic method on the InputManager.Current instance. object stylusLogic = inputManagerType.InvokeMember("StylusLogic", BindingFlags.GetProperty | BindingFlags.Instance | BindingFlags.NonPublic, null, InputManager.Current, null); if (stylusLogic != null) { // Get the type of the device class. Type devicesType = devices.GetType(); // Loop until there are no more devices to remove. int count = devices.Count + 1; while (devices.Count > 0) { // Remove the first tablet device in the devices collection. devicesType.InvokeMember("HandleTabletRemoved", BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.NonPublic, null, devices, new object[] { (uint)0 }); count--; if (devices.Count != count) { throw new Win32Exception("Unable to remove real-time stylus support."); } } } } }
weixin_38098817 2018-01-02
  • 打赏
  • 举报
回复
这段代码对我好像起作用,最近这个问题一直没有发生了public static void DisableWPFTabletSupport() { // Get a collection of the tablet devices for this window. TabletDeviceCollection devices = System.Windows.Input.Tablet.TabletDevices; if (devices.Count > 0) { // Get the Type of InputManager. Type inputManagerType = typeof(System.Windows.Input.InputManager); // Call the StylusLogic method on the InputManager.Current instance. object stylusLogic = inputManagerType.InvokeMember("StylusLogic", BindingFlags.GetProperty | BindingFlags.Instance | BindingFlags.NonPublic, null, InputManager.Current, null); if (stylusLogic != null) { // Get the type of the device class. Type devicesType = devices.GetType(); // Loop until there are no more devices to remove. int count = devices.Count + 1; while (devices.Count > 0) { // Remove the first tablet device in the devices collection. devicesType.InvokeMember("HandleTabletRemoved", BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.NonPublic, null, devices, new object[] { (uint)0 }); count--; if (devices.Count != count) { throw new Win32Exception("Unable to remove real-time stylus support."); } } } } }
weixin_38107053 2017-12-25
  • 打赏
  • 举报
回复
据我所知这是一个从.Net 4.5.1就有一个类似的Bug,在.Net 4.7中才修复。

476

社区成员

发帖
与我相关
我的任务
社区描述
其他技术讨论专区
其他 技术论坛(原bbs)
社区管理员
  • 其他技术讨论专区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧