This article is written in both English and Chinese.
在 win10 的 17025(直到 17134 也就是正式版 1803 也没有修复) 可以容易让 UWP 触摸失效。做法是创建一个窗口背景是透明的 wpf 程序,把他置顶,这时所有 uwp 程序就无法触摸。在正式版 17134 是所有的触摸程序都触摸失效,除了可以把触摸转鼠标的程序如 VisualStudio 和 QQ 还能使用,如 Edge 和 Chrome 都无法使用。
I found the easy way to make the UWP app touch not work in win10 17025(until 17134). To create a wpf app with transparent background and make it Topmost, you can see all of the UWP app’s touch not work.
中文
写英文的原因是给微软报这个问题,现在发在 微软反馈 希望大家投票。
步骤:
-
创建一个 wpf 程序
-
设置 wpf 的窗口最大化
-
设置 wpf 程序的背景为透明
-
启动 wpf 程序
这时就可以看到 Edge 等软件都无法触摸
在检查的时候可以使用ManipulationDemo,可以看到在触摸的时候没有 Pointer 消息。
下面是关闭 wpf 程序之后,可以看到最下面有 Pointer 消息
下面是这个wpf软件代码:
public MainWindow()
{
InitializeComponent();
AllowsTransparency = true;
WindowStyle = WindowStyle.None;
WindowState = WindowState.Maximized;
Background = Brushes.Transparent;
Topmost = true;
}
解决方案
最新的微软补丁August 30, 2018—KB4346783 修复了这个问题,只需要在用户的设备安装这个补丁就可以解决
下面是不使用补丁的方法
如果设置了一个窗口满足下面的属性
WindowStyle = WindowStyle.None;
WindowState = WindowState.Maximized;
或
WindowStyle="None"
AllowsTransparency="True"
那么就必须要设置 ResizeMode="NoResize"
不然就会出现下面的问题
-
在 win10 17025-17134 版本,如果同时设置
AllowsTransparency = true;
窗口下面所有程序触摸失效 -
还原窗口再最大化,窗口出现偏移
-
切换屏幕,窗口出现偏移
English
Step:
-
Create a wpf app
-
Set the wpf app’s windows state is Maximized
-
Set the wpf app’s windows background is transparent
-
Run the wpf app
Then you can see all of the uwp app’s such as edge and setting touch not work.
You can use ManipulationDemo to help you see the Pointer message that cant get when touch. I use ManipulationDemo to find the pointer message have not be received. The app can only receive the mouse message.
I took an image that shows the pointer message when I closed the wpf app.
This is the wpf app’s code:
public MainWindow()
{
InitializeComponent();
AllowsTransparency = true;
WindowStyle = WindowStyle.None;
WindowState = WindowState.Maximized;
Background = Brushes.Transparent;
Topmost = true;
}
This is my system and I think in win10 17025 the windows cant make the app uses pointer message to work that exists another transparent background app in above.
Solution
Microsoft has fixed this issue in .NET Framework August 2018 Preview of Quality Rollup.
Addresses an issue where touch and mouse events were handled differently in Windows Presentation Foundation (WPF) applications that have a transparent overlay window.
If you have a Window that set the following properties.
WindowStyle = WindowStyle.None;
WindowState = WindowState.Maximized;
Or
WindowStyle="None"
AllowsTransparency="True"
You must set ResizeMode="NoResize"
to avoid some problems as
-
All applications lost touch or stylus if a WPF transparent window covers on them.
-
Windows appears offset when set it to
Maximized
fromNormal
. -
Windows appears offset when switch screen.
本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。欢迎转载、使用、重新发布,但务必保留文章署名林德熙(包含链接:http://blog.csdn.net/lindexi_gd ),不得用于商业目的,基于本文修改后的作品务必以相同的许可发布。如有任何疑问,请与我联系。