Click event is rarely raised when using touch
- Dominant language
- C#
- Stars
- 7.7k
- Forks
- 1.3k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 61
Description
* .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](https://github.com/dotnet/wpf/files/2698305/Touch.zip)
***MainWindow.xaml:***
```
```
***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:***
```
```
***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
Contributor guide
Assessment
This issue has not been assessed yet.