Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

On Windows 10 (1803), all applications lost touch or stylus if a WPF transparent window covers on them

Tags:

c#

wpf

uwp

If I create a new WPF application with a simple empty window like the code shown below, I find that all applications which are covered by the WPF app lost touch or stylus reaction. This can only be reproduced when Windows 10 is upgraded to 1803 (10.0.17134.0).

<Window x:Class="TheWPFCoveringWindow.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        WindowStyle="None" WindowState="Maximized"
        AllowsTransparency="True" Background="Transparent"
        Topmost="True">
    <Button Content="Test" Width="200" Height="100" />
</Window>

I wrote another WPF application to find out what happened. So I add a StylusDown event to the Window like the code shown below:

// This code is in another WPF application.
private void OnStylusDown(object sender, StylusDownEventArgs e)
{
    // Set a breakpoint here.
}

But the breakpoint never reached until I closed the transparent WPF window which is on top.

I pushed the very simple code to GitHub: dotnet-campus/TouchIssueOnWindows10.0.17134. Cloning it might help a little.

Why does this happen and how to solve it? Any reply is appreciated.

like image 365
walterlv Avatar asked May 17 '18 02:05

walterlv


People also ask

Does Microsoft still support WPF?

Microsoft has faith in WPF as a UI framework Net Core 3.0. This demonstrates that Microsoft still has faith in WPF as a user interface framework, and the company is still willing to invest in it by updating and integrating it with its new offerings.”

What is the need of WPF when we had Windows Forms?

WPF allows developers to create event-driven rich client applications for usage on the Windows operating system. WPF can be used to develop and design both Windows applications and web applications while WinForms can only be used to develop and design Windows applications.

What is WPF stylus?

Stylus: "Provides access to general information about a tablet pen." However if you develop an application with touch-screen support you will realize that their events aren't relly isolated and separated due bubbled events (see attached image).


1 Answers

Updated

Microsoft has fixed this issue in .NET Framework August 2018 Preview of Quality Rollup.

  • August 30, 2018—KB4346783 (OS Build 17134.254)

Addresses an issue where touch and mouse events were handled differently in Windows Presentation Foundation (WPF) applications that have a transparent overlay window.


Original

After a whole week's debugging, I finally find out the solution.

Just add a ResizeMode="NoResize" property for the Window as the code shown below:

<Window x:Class="TheWPFCoveringWindow.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        WindowStyle="None" WindowState="Maximized"
        AllowsTransparency="True" ResizeMode="NoResize"
        Background="Transparent" Topmost="True">
    <Button Content="Test" Width="200" Height="100" />
</Window>

@lindexi has posted this issue and this solution into his post. If you want more information about this issue, read win10 17025 touch bug - lindexi for more details. (This post is written in multiple languages, so you'll miss nothing even if you ignore the unknown characters.)

Actually, I still can't figure out why this property helps.

Could anyone explain the reason for this issue?

like image 65
walterlv Avatar answered Nov 01 '22 19:11

walterlv