Skip to content

Click event is rarely raised when using touch #194

Open
@Jogge

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugProduct bug (most likely)

    Type

    No type

    Projects

    Status

    Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions