Skip to content

Click event is rarely raised when using touch #194

Open

Description

@Jogge
  • .NET Core Version:
    3.0.100-preview-009812
  • Windows version:
    Version 1803
  • 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:

<Window 
    x:Class="Touch.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Height="400" Width="400">
    <StackPanel>
        <TextBox Text="{Binding Integer}" FontSize="48" />
        <TextBox Text="{Binding Integer}" FontSize="48" />
    </StackPanel>
</Window>

MainWindow.xaml.cs:

public partial class MainWindow
{
    public MainWindow()
    {
        InitializeComponent();

        DataContext = new ViewModel();
    }
}

ViewModel.cs:

public class ViewModel
{
    private int _integer;

    public int Integer
    {
        get => _integer;
        set
        {
            _integer = value;
            new DialogWindow().ShowDialog();
        }
    }
}

DialogWindow.xaml:

<Window
    x:Class="Touch.DialogWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Height="200" Width="200">
    <Grid>
        <Button Content="Close" Click="OnClick" />
    </Grid>
</Window>

DialogWindow.xaml.cs:

public partial class DialogWindow
{
    public DialogWindow()
    {
        InitializeComponent();
    }

    private void OnClick(object sender, RoutedEventArgs e)
    {
        Close();
    }
}

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 than Button, for example TextBox. It is therefore not a solution to switch to TouchDown 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

Activity

  1. changed the title [-]Click event is not raised when using touch[/-] [+]Click event is rarely raised when using touch[/+] on Dec 21, 2018
  2. stevenbrix commented on Jan 4, 2019

    @stevenbrix
    Contributor

    @Jogge can you elaborate on why using touch events is not a solution?

  3. added
    Bug
    on Jan 4, 2019
  4. rladuca commented on Jan 4, 2019

    @rladuca
    Member

    @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.

  5. added this to the Future milestone on Jan 4, 2019
  6. StefGuichard commented on Mar 21, 2019

    @StefGuichard

    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 ?

  7. Jogge commented on Mar 22, 2019

    @Jogge
    Author

    @StefGuichard unfortunately we have not found any workarounds, other than using the TouchDown event... 😟

  8. Stannieman commented on Mar 22, 2019

    @Stannieman

    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.

  9. pstow commented on Apr 3, 2019

    @pstow

    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.

  10. HartlD2 commented on Apr 28, 2019

    @HartlD2

    Hello are there any workarounds or fixes of this bug available?

  11. hunterzzzpro commented on Apr 29, 2019

    @hunterzzzpro

    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.

  12. Stannieman commented on Apr 29, 2019

    @Stannieman

    @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).

  13. pstow commented on Apr 29, 2019

    @pstow

    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.

  14. hunterzzzpro commented on Apr 29, 2019

    @hunterzzzpro

    @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!)

  15. Stannieman commented on Apr 30, 2019

    @Stannieman

    @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.

  16. 7 remaining items

  17. Jogge commented on Oct 26, 2022

    @Jogge
    Author

    @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
    
  18. Stannieman commented on Oct 26, 2022

    @Stannieman

    @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.

  19. caomfan commented on Jun 4, 2024

    @caomfan

    @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
    image

    1717506398754-1717506297385-20240604_205803.mp4

    But it is normal to open the modal window using a button

  20. tbeltram commented on May 6, 2025

    @tbeltram

    Does anyone have a fix for this? DisableStylusAndTouchSupportSwitchName works, but then the lists are not smooth-scrollable anymore, so its not an option.

  21. tbeltram commented on May 6, 2025

    @tbeltram

    I noticed even if I manually capture the OnTouchDown event, and Raise a Click event, the Click-Event is not captured many times.

  22. KKirsch-GIT commented on Dec 8, 2025

    @KKirsch-GIT

    Why is this still an ongoing issue since 2018

  23. added
    Priority:1
    on Sep 29, 2026
  24. self-assigned this
    on Oct 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

🚧 work in progressBugPR ProposedPriority:1Wave1area-Touch

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions