首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么自windows 10 (1809/1903)以来,我的所有WPF应用程序都无法拖出它们的窗口,例如调整窗口大小或进行拖放?

为什么自windows 10 (1809/1903)以来,我的所有WPF应用程序都无法拖出它们的窗口,例如调整窗口大小或进行拖放?
EN

Stack Overflow用户
提问于 2019-05-29 06:42:23
回答 1查看 590关注 0票数 5

有一天,我发现我所有的WPF应用程序都无法拖出窗口,并且我无法通过实时预览来调整任何窗口的大小。

我的问题是,为什么会发生这种情况,我如何解决这个问题?

您可以查看下面显示的动画图像:

您可以注意到,当我的游标在窗口外时,调整大小立即停止,当光标第一次离开窗口时,窗口保持大小。如果光标重新进入窗口区域,并且重新调整窗口大小。

不仅我编写的所有WPF应用程序,而且其他的WPF应用程序都复制:

  • Visual Studio 2017/2019
  • 斯诺普
  • ScreenToGif
  • 等。

非WPF应用程序行为正确。

这种现象发生在几个月前,因为我的系统版本是Windows 10 (1809年),现在我的系统版本是Windows 10 (1903年),这个问题停滞不前。从.NET框架3.5/4.5/4.8和.NET Core3.0嵌入的WPF应用程序。

Update1:我刚刚清理了我的所有驱动器,用一些核心应用程序重新安装了Windows10Professional(1903年,客户版),这个问题仍然存在。核心应用是Chrome,PalmInput IME,iTunes。

Update2:我编写了一个WPF应用程序来处理窗口消息。当我调整外部窗口的大小时,我发现49757消息将停止接收。这条消息在我朋友的系统上正常运行。

EN

回答 1

Stack Overflow用户

发布于 2019-07-21 17:09:38

更新:

正如所指出的由WPF团队成员推荐的在WPF中禁用手写笔和触摸支持的方法是使用App.config中的Switch.System.Windows.Input.Stylus.DisableStylusAndTouchSupport设置,如下所示:

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <runtime>
    <AppContextSwitchOverrides value="Switch.System.Windows.Input.Stylus.DisableStylusAndTouchSupport=true" />
  </runtime>  
</configuration>

还要注意的是,这不是一个解决方案,而是一个工作,这可能不是一个很好的适合所有的情况。

原版:

马库斯·艾森斯特为这个问题找到了一个周旋。通过禁用WPF中的平板支持,您将体验到预期的行为。我已经在我的机器上进行了测试和工作(Windows10Version1903& .NET Framework4.6.2):

代码语言:javascript
复制
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 stylusLogic returned 
            // from the call to StylusLogic.  
            Type stylusLogicType = stylusLogic.GetType();


            // Loop until there are no more devices to remove.  
            while (devices.Count > 0)
            {
                // Remove the first tablet device in the devices collection.  
                stylusLogicType.InvokeMember("OnTabletRemoved",
                        BindingFlags.InvokeMethod | 
                        BindingFlags.Instance | BindingFlags.NonPublic,
                        null, stylusLogic, new object[] { (uint)0 });
            }
        }
    }
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56354510

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档