Open Jogge opened 5 years ago
@Jogge can you elaborate on why using touch events is not a solution?
@stevenbrix Touch is not first class in WPF as it is in UWP. If touch doesn't promote to mouse (and therefore click) the button will not click.
I've got the same problem. In your project you can change clickEvent by Mousedown or PreviewMouseDown. On TouchScreen you will have the same problem if you use your finger. With mouse it works well. Any news or workaround ?
@StefGuichard unfortunately we have not found any workarounds, other than using the TouchDown event... 😟
I seems to be related to that issue 450. At the moment you click the close button in dialog and it doesn't work you can see that it has 0 TouchesOver on MainWindow but 2 TouchesOver on DialogWindow. This is not correct as I only ever touched the screen with 1 finger at a time.
I don't know exactly how .NET handles touch internally but I feel the same part of WPF code is responsible for both cases.
I have had this issue with numerous projects over the last four years. I have been able to correct the issue by switching from a multi-touch driver to a single-touch driver on our touch screens. Unfortunately, I have not been able to find a single touch driver for Windows 10 that works yet. I may have to downgrade my latest project to Windows 7.
Hello are there any workarounds or fixes of this bug available?
This is still a huge issue, ShowDialog doesn't work well with multi-touch displays.
It does respond if I tap the Window 8-10 times then it becomes responsive. I have tried all of the focus options, almost every setting and nothing makes a difference, I have had to make my own showDialog functionality, but it needs to be shown with ShowDialog ideally.
@hunterzzzpro can you share how you do this? In our main app we have an abstraction around ShowDialog anyway so this kind of workaround might work better than other things we tried (which all introduced their own bugs).
I use WPF on Beckhoff touch screens and was able to get my project to work with the eGalaxTouch_5.14.0.17601 driver in single touch mode.
@Stannieman My requirements were to have the window pop up and not allow the user to click outside of that window.
So I did the following:
Used .Show()
set the window.Topmost = true;
then made an event for the MainWindow to subscribe too that makes a hidden rectangle visible, but it's transparent. This stops any of the buttons from being clicked/pressed.
Very hacky which is why I need ShowDialog() fixed. Probably won't help in your case, but it's a temp fix for me (Tight deadlines!)
@hunterzzzpro yeah approach with overlay is actually ok for us, but Show() not blocking until dialog is closed is kind of a problem.
Actually now that I think about it, probably the fact that Show() (and thus really the main window's message loop) does not wait for the dialog to close is exactly why it works for you.
Slightly offtopic, but here is how we are doing modal loops without ShowDialog
in WinForms. It's how PropertyGrid shows its dropdown popups. No idea if it helps with this particular problem.
This issue happens when Button elements are located in a user control or window along side a text box or could be with other elements.
You need to assign a touch down event along side assigning a command parameter and a command on the button element.
If the touch down event is fired, manually fire the command. Example below
MapEntity commandParameter = (MapEntity)(((Button)sender).CommandParameter);
var viewModel = (FindADISViewModel)DataContext;
if (viewModel.OpenDIS.CanExecute(commandParameter))
viewModel.OpenDIS.Execute(commandParameter);
Disabling the RealTimeStylus works with me. See the next article: "... As a result, to use WM_TOUCH to receive touch messages from a WPF window, you must disable the built-in stylus support in WPF ..." https://docs.microsoft.com/en-us/dotnet/desktop/wpf/advanced/disable-the-realtimestylus-for-wpf-applications
Disabling the RealTimeStylus works with me. See the next article: "... As a result, to use WM_TOUCH to receive touch messages from a WPF window, you must disable the built-in stylus support in WPF ..." https://docs.microsoft.com/en-us/dotnet/desktop/wpf/advanced/disable-the-realtimestylus-for-wpf-applications
You should, instead, use this AppContext switch:
This is much cleaner and is present in .NET Framework 4.8 as well as version of .NET Core (and beyond) that support WPF. I believe it is also available in .NET Framework 4.7.2, but I don't have the history to hand right now so I don't feel comfortable stating that as fact. If you enable the switch and you try to access Tablet.TabletDevices they should be empty, even on a machine with touch/stylus devices. Then you know its working and WPF (via WISP) will not eat various touch-centric Windows messages.
@Jogge We tested this issue on a fresh machine (Win 22H2, OS build : 25232.1000 with .NET version 6.0.402 installed) and we couldn't replicate the issue. The touch event was firing with every click. You can check the attached video for the reference.
Can you confirm if you're still seeing this issue? If yes, then please let us know what version of .net and win version are you currently on.
The bug still occurs for the following computer running the program in self-contained .net 6 application, with target framework net6.0-windows and runtime win-x86:
Processor Intel(R) Core(TM) i5-5200U CPU @ 2.20GHz 2.20 GHz
Installed RAM 4,00 GB (3,79 GB usable)
System type 64-bit operating system, x64-based processor
Pen and touch Touch support with 10 touch points
Edition Windows 10 Pro
Version 21H2
Installed on 14-10-2021
OS build 19044.1526
Experience Windows Feature Experience Pack 120.2212.4170.0
It is a long time since this tablet has been windows updated. I will do that now and check if it still occurs.
@anjalisheel-wpf After updating windows with the latest updates the issue still occur with the same .net 6 self-contained application.
Heres the system specifications after windows updates:
Processor Intel(R) Core(TM) i5-5200U CPU @ 2.20GHz 2.20 GHz
Installed RAM 4,00 GB (3,79 GB usable)
System type 64-bit operating system, x64-based processor
Pen and touch Touch support with 10 touch points
Edition Windows 10 Pro
Version 22H2
Installed on 14-10-2021
OS build 19045.2193
Experience Windows Feature Experience Pack 120.2212.4180.0
@anjalisheel-wpf I believe it does not occur on Win 11 for some reason, on 10 and older you should be able to reproduce. I don't know why cause it looks like all this touch to mouse promotion is done in WPF and not by Windows.
@anjalisheel-wpf I believe it does not occur on Win 11 for some reason, on 10 and older you should be able to reproduce. I don't know why cause it looks like all this touch to mouse promotion is done in WPF and not by Windows.
Unfortunately this problem still exists on win11
https://github.com/dotnet/wpf/assets/30285397/6b688f1f-b0b7-4e1c-8374-85e52b50ebf0
But it is normal to open the modal window using a button
Does the bug reproduce also in WPF for .NET Framework 4.8?: Yes
Problem description: Click event is rarely raised when using touch in new windows.
Actual behavior: Touching (clicking) the button does nothing the first 10 times. 11th time the click event is raised.
Expected behavior: Click event on button should be raised on first touch.
Minimal repro: Touch.zip MainWindow.xaml:
MainWindow.xaml.cs:
ViewModel.cs:
DialogWindow.xaml:
DialogWindow.xaml.cs:
When one of the textboxes has content changed, and you uses touch to focus the other textbox, the
DialogWindow
will pop up. Now the problem occurs, and we have to press (touch) the close button multiple times (etc. 11 times on one of our devices) before the click event happens and the dialog closes.TouchDown
event works properly. We're also experincing this on other elements thanButton
, for exampleTextBox
. It is therefore not a solution to switch toTouchDown
event. Everyhing in the new window seems to be buggy.Related links: https://stackoverflow.com/questions/53851382/wpf-click-event-is-not-raised-on-touch-screen https://stackoverflow.com/questions/28441538/touching-a-wpf-button-does-sometimes-not-invoke-the-click-handler-under-windows