dotnet / dotnet/wpf

WPF RepeatButton fires only once on TouchUp when hosted in ListBox

Open
#8,223 2 comments 1 reaction 0 assignees View on GitHub
Investigate
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

### Description

Using a touchscreen, the RepeatButton fails to raise repeated Click events when the button is hosted inside a ListBox or ListView.

Similarly, the grip of a Slider (when hosted in a ListBox) cannot be grabbed by touching the screen.

Both Slider and RepeatButton work as expected when interacted with a mouse.

### Reproduction Steps

[ListBoxRepeatButtonBug.zip](https://github.com/dotnet/wpf/files/12614343/ListBoxRepeatButtonBug.zip)

### Expected behavior

RepeatButton raises repeated click events when touched/depressed.
Should be able to grab/slide a Slider control

### Actual behavior

RepeatButton raises a Click event only once on TouchUp.
Cannot slide a Slider

### Regression?

No. Repro'd on other .NET versions

### Known Workarounds

None known

### Impact

Affects any WPF application where the user interacts with a ListBox using a touchscreen

### Configuration

* .NET 6.0
* Win10 Pro 10.0.19045 Build 19045
* Arch: x86/64
* Does the bug repro in Framework 4.8: Yes
* Is this bug related specifically to tooling in Visual Studio (e.g. XAML Designer, Code editing, etc...)? No
* Specific to .NET 6: No. Also repro'd on Framework 4.8, Core 3.1, NET 7.

### Other information

The attached repro was inspired by a similar bug report https://github.com/dotnet/wpf/issues/4512

That particular bug was observed in Core 3.1 but is no longer a problem on NET6.
I have tested that and can confirm that I also see that as fixed since NET6.

During my investigation for this new bug, I tried disabling the Touch API using two methods:
* https://learn.microsoft.com/en-us/dotnet/desktop/wpf/advanced/disable-the-realtimestylus-for-wpf-applications?view=netframeworkdesktop-4.8
* Switch.System.Windows.Input.Stylus.DisableStylusAndTouchSupport=true

This makes the touchscreen behave instead like a mouse touchpad.
The repeat Click event of the RepeatButton will be raised as expected in this scenario, but to initiate the ButtonDown/depressed state the user must double-tap the screen so this is not a viable solution.

On further investigation, I started monitoring the TouchDown/Up/Move/Enter/Leave events of the RepeatButton.
When the button works I see the following event sequence:
* TouchEnter
* TouchDown
* Click (n times)

Then when I release
* TouchUp
* TouchLeave

When the RepeatButton doesn't work (ie is inside a ListBox), I see the following sequence:
* TouchEnter
* TouchDown
* TouchLeave

When I release
* Click (once)
* TouchEnter
* TouchLeave

There is a spurious TouchLeave event while the button is depressed which seems to inhibit any further Click events.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.