Bug 60314 - ItemSelected/ItemTapped are raised twice in *grouped* ListView on UWP
Summary: ItemSelected/ItemTapped are raised twice in *grouped* ListView on UWP
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.5.0
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
: 60748 ()
Depends on:
Reported: 2017-10-23 00:49 UTC by Torsten Seemann
Modified: 2018-01-31 10:54 UTC (History)
8 users (show)

Tags: listview, grouping, itemselected, itemtapped, ac
Is this bug a regression?: ---
Last known good build:

ItemTapped called twice. (305.95 KB, application/zip)
2017-10-23 09:35 UTC, Marcin Gierlasiński
Sample solution demonstrating the problem (312.47 KB, application/x-zip-compressed)
2017-10-23 10:44 UTC, Torsten Seemann

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report for Bug 60314 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description Torsten Seemann 2017-10-23 00:49:09 UTC
When tapping (or clicking) an item in a grouped listview (ListView.IsGroupingEnabled=true) on UWP, the ListView.ItemSelected and ListView.ItemTapped events are both raised twice; once for the item immediately preceding the tapped item and once for the actual selected item. This seems to happens on Windows only. On Android both events are raised just for the tapped item, as expected.

NB! This bug was introduced with v2.4 and still exists in v2.5.0.19271-pre2. It is not the same as bug 44886.
Comment 1 Paul DiPietro [MSFT] 2017-10-23 03:04:21 UTC
Can you please provide a reproduction and verify that you have done a full clean and rebuild of the project?
Comment 2 Marcin Gierlasiński 2017-10-23 09:35:37 UTC
Created attachment 25396 [details]
ItemTapped called twice.

Hi, I confirm there is an issue with tap event handling on list after upgrading to 2.4. I attached sample project when ItemTapped is called twice. When I add TapGestureRecognizer in DataTemplate, both are fired - ItemTapped (but this time once) and Tapped on gesture recognizer. In Forms 2.3 behaviour was different - if there was gesture recognizer in DataTemplate, ListView's events for tapping and selecting were not fired. In my working project I have also issue with ItemSelected called twice but there is quite complex DataTemplate and I wasn't able to reproduce it in this sample.
Comment 3 Torsten Seemann 2017-10-23 10:44:03 UTC
Created attachment 25397 [details]
Sample solution demonstrating the problem

1. Build and run UWP project
2. Tap or click any contact in the grouped listview
3. Watch the debug output for duplicate events
Comment 4 Paul DiPietro [MSFT] 2017-10-24 16:01:44 UTC
Thank you for the reproduction.
Comment 5 Paul DiPietro [MSFT] 2017-11-18 14:19:00 UTC
*** Bug 60748 has been marked as a duplicate of this bug. ***
Comment 6 John Hardman 2017-11-22 17:39:17 UTC
I am seeing ItemTapped being fired twice on UWP as a result of a mouse click, even if the ListView's IsGroupingEnabled = false 

Should I raise this as a separate bug, or can it be handled under the auspices of this one?
Comment 7 Torsten Seemann 2017-11-30 01:40:39 UTC
We just updated our solution to use the latest Xamarin Forms build, only to discover that this bug has now gotten even worse! :(

Before 2.5, we were able to workaround the bug by "throttling" the ItemTapped/ItemSelected events and only accepting events if no additional event was received within .2 seconds. Thereby we could assume that the last event fired did actually represent the item that had been selected in the ListView.

After upgrading to 2.5, we no longer get *any* event representing the item that was selected. We now only get one event, which is kind of an improvement, but the event still fires for what seems to be a random item in the list - not the one that was selected/tapped.

This is really disappointing. The bug makes the ListView totally useless in UWP. I get that Windows Universal is probably not the most widely targeted platform by Xamarin Forms apps, but not prioritizing to fix a bug like this for sure doesn't improve on that.
Comment 8 nitemsg 2017-12-21 10:51:40 UTC
Indeed really disappointing and frustrating as our entire app is using grouped listviews. Its 2018 and we cant have a working ItemSelected event (UWP)... I mean, really?
Comment 9 uwantfries 2018-01-31 10:54:45 UTC
I am also having problems with grouped items selecting using UWP older version of the build environment & XF 23.x was fine but anything beyond this is broken (using the current Xamarin beta).

Please see video. 1st is Android 2nd is UWP.


ETA for a fix plz? PS - What is the master case for this?