dotnet / dotnet/wpf

WPF topmost window Cannot touch in tablet

Open
#2,054 1 comment 4 reactions 0 assignees View on GitHub
area-Touch Bug
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

* .NET Core Version: (e.g. 3.0 Preview1, or daily build number, use `dotnet --info`) 3.0
* Windows version: (`winver`) All version
* Does the bug reproduce also in WPF for .NET Framework 4.8?: Yes
* Is this bug related specifically to tooling in Visual Studio No



**Problem description:**

All you need is two tablets (or other touch device) and a WPF window set topmost. Here is the demo.

```xml


```

Next, plug in these two tablets (called T1&T2) in turn, and run the demo.(you can run the demo first, if you like. it doesn't change the result).Everythin is fine,it works.

BUT, when you plug out the second tablet (T2), you will find the demo cannot response for any touch message from the first one(T1). Until you close this window, or plug out and plug in T1 again.(Well other parts in you computer do get the touch message from T1, as well as other windows in your demo but this topmost window)

I made some efforts to figure out why. And it seems that there is some hooks didn't remove when a `TouchDevice` is disconnected.But I can't go any further.

A good news is I found a way by chance, may fix this bug.

use

```csharp
new WindowInteropHelper(this).EnsureHandle();
```

in constructor. Or just call this method BEFORE the window show,like

```csharp
var window =new TopmostWindow();
new WindowInteropHelper(window).EnsureHandle();
window.show();
```

The bug will disapper.

But who want add this in every topmost window.By the way, it seems to have a conflict with `AllowTransparent=True` in some cases.

Hope this bug get fixed soon.

Copied from: [WPF topmost window Cannot touch in tablet - Developer Community](https://developercommunity.visualstudio.com/content/problem/196879/wpf-topmost-window-cannot-touch-in-tablet.html )

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.