Repository navigation
Description
This issue has been moved from a ticket on Developer Community.
Hello I'm developing a WPF application to be used with touch devices (Running Win 10 full).
There is one scenario where the touch stops responding as expected.
If I have a TextBox and open a dialog (ShowDialog()) then the dialog won't handle any touch and will ignore the user:
A) 1 touch ignored - if using single touch driver.
B) 10 touches ignored - if using multi touch driver.
And after that it starts responding normally again.
I have attached a video show casing this issue and also a test project so you can easily replicate (using Windows Simulator w/ touch or a touch monitor)
In the video you can see that when opening the dialog through a button it responds as expected but if opened through a TextBox it will then have a touch issue.
textbox-showdialog-touch-issue.mp4
The code being used is just this:
private void TextBox_PreviewMouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
// This cause touch issues within the dialog.
// (1 touch ignored w/ single touch monitor/driver - 10 touches ignored w/ multi touch monitor/driver)
new DialogWindow(). ShowDialog();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
new DialogWindow(). ShowDialog();
}
Windows 10
VS 2019
.NET 4.6.1 (but it was also tested with 4.8, exactly same issue)
Original Comments
Visual Studio Feedback System on 1/20/2020, 06:41 PM:
We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.
Visual Studio Feedback System on 1/30/2020, 01:12 PM:
This issue is currently being investigated. Our team will get back to you if either more information is needed, a workaround is available, or the issue is resolved.
Original Solutions
(no solutions)
Activity
qtbui159 commentedon Feb 9, 2020
This is an irritated and old bug which exists from .net framework 3.5. All first touch of non-button popup window(modal)would be ignored
wcfCode commentedon Jul 30, 2020
Hope the problem gets attention.
wcfCode commentedon Jul 31, 2020
Is there a temporary solution?
qtbui159 commentedon Jul 31, 2020
你所有需要弹窗的地方都用button来做就行
MitSeven commentedon Aug 11, 2020
I have the same error. I wonder why it takes 10 touches. I am currently doing a temporary fix using Dispatcher.BeginInvoke or DispatcherInvokeAsync
Mzazvor commentedon Mar 4, 2021
Hi,
@MitSeven Could you elaborate on your temporary fix? I had spend few hours looking for progress in this problem and there seems to be none. We do unfortunately have those same 10touches on our showDialog window.
Thanx for any advice
Martin
Mzazvor commentedon Mar 4, 2021
For anyone after me... I managed to get it somewhat working with the use of StylusDownEvent.
private void Button_StylusDown(object sender, System.Windows.Input.StylusDownEventArgs e)
{
var vm = (DressingPopupViewModel)this.DataContext;
Button _myButton = (Button)sender;
string value = _myButton.CommandParameter.ToString();
if (vm.CanDoCommand(value))
{
vm.DoCommand(value);
}
e.Handled = true;
}
This method handles touches, where Binding to command of VM handles mouseClicks with no problem. It is probably not a clean solution but it is a few lines worth trying in your problem.
GuangSunshine commentedon May 7, 2021
I had similar issue on a Button in my code, and the fix is rather simple for me -- do NOT handle the Touch and PreviewMouse events, just let the touch be promoted to Click event and do things there:
<Button Click="btnClick">. If you requirement allows you to do that in your case, that should be the solution. If you can't wait till the Click event, please read on:My analysis of this problem:
When a Button is being touched, WPF use one instance of some handler (let's call it touchHandler1 of type FingerTouchEventHandler) to handle the whole tunneling and bubbling events from PreviewTouchDown until the final TouchUp. If in the PreviewTouchUp or even TouchUp event handler, you show a new dialog or a MessageBox, the focus is switched to the new dialog, the touchHandler1 on the Button gets stuck, it does not get handled completely.
If now you touch again, the WPF sees there is already one active FingerTouchEventHandler -- touchHandler1 and it is still active, so it wrongly thinks the user is putting a second finger on the screen, WPF proudly thinks "I can handle multi-touch!", so it creates touchHandler2, but since now there are two fingers on the screen, somehow the "second finger" is also stuck, so nothing happens on the screen;
Same thing happens when the third touch occurs, WPF creates touchHandler3. This goes on and on until the 11th touch happens. WPF only supports 10 multi-touches (because human beings have 10 fingers), now it treat this 11th touch as part of the tunneling and bubbling sequence of touchHandler1, and completes touchHandler1. Subsequent touches complete the touchHandler2 etc, now everything is back to normal again.
The above points 1, 2, 3 are my guess, they matches my observation well, then the solution could now also be obvious:
in your
TextBox_PreviewMouseDown(), BEFORE callingnew DialogWindow(). ShowDialog();just saye.Handled = true;I tried this solution in my code, it works for me. Please give it a try and let us know the result. Good luck!lasharn commentedon Nov 15, 2021
This didn't work for me although your explanation for the underlying issue does make sense to me.
I did try what @MitSeven suggested and call
ShowDialog()within aDispatcher.BeginInvokecall and that did work for me.This makes sense with your explanation since queuing the dialog call won't let the button get stuck during the event handler and therefore no extra touch handlers will be created.
marcauto commentedon Feb 9, 2022
Is this a problem only with Windows 10 or is a problem also in the other Windows (7, p.e)?
GuangSunshine commentedon Feb 9, 2022
Only tried on Windows 10, do not know about other Windows.
marcauto commentedon Feb 17, 2022
for the ones that don't need the multi touch functionality, is possible to deactivate the multi touch driver?
heathleger commentedon Aug 1, 2022
8 remaining items
isasin commentedon Sep 17, 2022
I see thanks for the answer I will try. so in that case, lets say I am using mouse and touch at the same time, then which handler should I use after I call this DisableWPFTabletSupport method? If I use mousedown event handler for touch too, does this matter? What do you say?
Mzazvor commentedon Sep 19, 2022
I just call it once on app startup. For clicks i just use regular command binding with mouse event and MVVM structure.
You will probably have to try that. I dont have any device to test it at the moment.
heathleger commentedon Feb 8, 2023
Thanks, this sample resolve my problem, but i still need the "StylusLogic". I use "Manipulation" to zoom ui element. There is a native smoth animation during user operating, The animation not work afther I remove the "StylusLogic". Please let me know how to fix this.
keeleycenc commentedon Sep 16, 2026
We are experiencing a similar issue in a WPF application targeting .NET 8 on Windows 10 with a touchscreen.
The affected window is opened using ShowDialog().
Observed behavior:
Our dynamic UI code has paths that call ShowDialog() synchronously from PreviewMouseLeftButtonDown or PreviewMouseLeftButtonUp handlers.
Could this be related to the issue reported here, even though the maximize button consistently works? Is there a confirmed fix or a recommended workaround for .NET 8?
90c89c6a27db7685c3762c847b93c102.mp4
miloush commentedon Sep 16, 2026
@keeleycenc would you have a simple repro project?
keeleycenc commentedon Sep 17, 2026
We are trying to fix and create a minimal reproducible application, which may take some time
keeleycenc commentedon Sep 18, 2026
@miloush Here is a minimal repro.
It is a dependency-free WPF application (net8.0-windows, no NuGet packages) with the
input pipeline instrumented, so the failure mode can be read directly off the dialog.
A touch screen is required; it does not reproduce with a mouse.
Steps
WpfModalTouchRepro.sln.ShowDialog()fromPreviewMouseLeftButtonDown.The first ten touches are discarded; the eleventh is handled. The counters in the
dialog show:
TouchDownandStylusDownincrease on every attempt, so the input does reach thewindow.
MouseDownandClickstay at zero until the eleventh attempt, so it is neverpromoted to mouse input.
The number of distinct
TouchDevice.Idvalues stops at ten. Each of the first tenattempts is assigned a new touch device, so WPF treats every one of them as an
additional finger. The eleventh attempt does not allocate an eleventh device: the pool
is exhausted, and the input is instead delivered as part of the first sequence, which
is still open. That sequence then completes, which is why
MouseDownandClickreachone on exactly the eleventh attempt.
Two independent conditions
The first determines whether touches are discarded at all, the second how many.
Measured on one machine with unchanged touch hardware and drivers:
ScrollViewerwithPanningModeother thanNonePreviewMouseLeftButtonDownPreviewMouseLeftButtonDownClickClick1.
ShowDialog()is called before the touch sequence completes. The nested messageloop prevents
TouchUpfrom reaching the active touch device, which can therefore nevercomplete. Opening the dialog from
Clickavoids this, because promotion has alreadyfinished by then.
2. Touch is routed through the manipulation pipeline. With
PanningMode.Nonepromotion is immediate and only a single touch device gets stuck. Otherwise promotion
is deferred and stuck devices accumulate.
This may refine the original report, which attributed the difference between "1 touch
ignored" and "10 touches ignored" to single-touch versus multi-touch drivers. In the
table above the only variable was the
PanningModeof an ancestorScrollViewer.Condition 2 is easy to satisfy without knowing it.
NavigationViewContentPresenterinWPF-UI hosts page content in a
DynamicScrollViewerthat ships withPanningMode=Bothand
IsManipulationEnabled=True. Note also that settingVerticalScrollBarVisibilityto
Disableddoes not turn off touch panning, asPanningModeis a separate property.Additional observation
While the dialog content is unresponsive, the close button in its title bar still
responds to the first touch. The title bar is a Win32 non-client area, so that input is
handled by the window manager and never enters WPF's touch promotion pipeline. The
window is therefore still receiving input normally, and only input that has to be
promoted is affected. This is also why our application lost its close button as
originally reported: it draws its own title bar as WPF content, which is an ordinary
element in the client area.
Deferring the
ShowDialog()call withDispatcher.BeginInvoke(DispatcherPriority.Input, ...)reduces the discarded touches from ten to at most one, but does not eliminate them:
whether
TouchUpis delivered before the queued callback runs depends on how long thefinger stays down. The README in the attachment lists the workarounds we evaluated.
Attachment
Video
5d814976039f43c0727a3111fa11f1ce.mp4
Source code
Reproduction.zip