Bug 58833 - ListView SelectedItem Binding does not fire
Summary: ListView SelectedItem Binding does not fire
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: 2.4.0
Hardware: Macintosh Mac OS
: High critical
Target Milestone: 2.4.0
Assignee: Bugzilla
: 58894 59129 59407 59579 ()
Depends on:
Reported: 2017-08-17 03:16 UTC by Rob Gibbens
Modified: 2018-04-18 16:43 UTC (History)
12 users (show)

Tags: ac android listview selecteditem
Is this bug a regression?: Yes
Last known good build:

repro project (296.90 KB, application/x-zip-compressed)
2017-08-17 21:17 UTC, Jimmy [MSFT]

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 on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Rob Gibbens 2017-08-17 03:16:47 UTC
(Possibly related to #58451 ?)

In my app, I have a ListView...

		ItemsSource="{Binding ClassTimes}" 
		SelectedItem="{Binding SelectedClass, Mode=TwoWay}"
		ItemTemplate="{StaticResource ClassDetailPageSelector}"

The SelectedItem is bound to a property in my ViewModel.

In Xamarin.Forms, this command is fired.  In, on Android, the command no longer fires. iOS still works. I haven't tested UWP.

I have tested this on two different machines.
Comment 1 Dániel Buga 2017-08-17 08:13:57 UTC
For me, it fires, sometimes, after a lot of tapping around in a crazy way. Worked fine before with 2.3.5-pre6, doesn't work with 2.4.0-pre1.
Comment 2 Dániel Buga 2017-08-17 08:30:10 UTC
Okay, more information: this seems to be happening only when the custom viewcell in datatemplate has context actions. Removing those context actions seems to resolve this issue.
Comment 3 Jimmy [MSFT] 2017-08-17 21:17:23 UTC
Created attachment 24284 [details]
repro project

### Overview
ListView items cannot be selected if the cell contains ContextActions.

### Platforms Affected

### Steps to Reproduce
1. Run the attached project on the affected platform above
2. Try to select an item in the ListView

### Expected Results
The cell will be highlighted to indicate it has been selected and the debug output will show that the SelectedItem has changed.

### Actual Results
The item is not highlighted and there is no output.

### Version Tests
2.4.0-pre1  BAD   GOOD
Comment 4 Jimmy [MSFT] 2017-08-18 22:14:53 UTC
*** Bug 58894 has been marked as a duplicate of this bug. ***
Comment 5 Rob Gibbens 2017-08-30 16:21:59 UTC
I just tried Xamarin.Forms  The SelectedItem DOES fire on most Android ListViews now, but they are still not firing when the ListView has a ItemTemplate set to a DataTemplateSelector
Comment 6 Jimmy [MSFT] 2017-08-31 14:31:03 UTC
*** Bug 59129 has been marked as a duplicate of this bug. ***
Comment 7 Samantha Houts [MSFT] 2017-09-11 23:07:20 UTC
Comment 8 Paul DiPietro [MSFT] 2017-09-12 16:55:02 UTC
*** Bug 59407 has been marked as a duplicate of this bug. ***
Comment 9 Paul DiPietro [MSFT] 2017-09-19 13:27:42 UTC
*** Bug 59579 has been marked as a duplicate of this bug. ***
Comment 10 Rob Gibbens 2017-09-19 22:19:36 UTC
I just tested with 2.4.0-pre3, and the problem still exists.  I can provide access to my repository to test with my app if you need it.
Comment 11 Samantha Houts [MSFT] 2017-09-19 23:14:02 UTC
Rob Gibbens: Please do! Thanks!
Comment 12 rfreschi 2017-09-19 23:40:14 UTC
Just grabbed 2.4.0-pre3
A listitem tap is fireing again when using a ContextAction.
With pre2 it would not fire.
Comment 13 Dániel Buga 2017-09-20 07:00:48 UTC
Although not sure about SelectedItem, my workaround (tapgesturerecogniser) does not reliably fire even with 2.4.0-pre3
Comment 14 Dániel Buga 2017-09-20 07:50:25 UTC
I retract my comment 13, it seems like I simply mistapped or my phone reacted slow, and was jumpy about it. Sorry
Comment 15 Samantha Houts [MSFT] 2017-09-20 16:58:00 UTC
rfreschi@hpsj.com Comment 12: Just to clarify, are you reporting that your problem is resolved or is it still broken for you?
Comment 16 rfreschi 2017-09-20 17:14:58 UTC
Samantha, my problem is resolved with pre3
Comment 17 Samantha Houts [MSFT] 2017-09-20 21:11:02 UTC
Outstanding. It sounds like this one is resolved after all. Thank you, all!
Comment 18 Valonk 2017-09-28 18:51:56 UTC
Since I've updated to from my ListView SelectedItem doesn't work at all anymore. 

Ive tested only on Android. Thats a strange issue. No Exceptions...nothing. The Command binding and SelectedItem binding stopped working.

Thats why i hate to update Xamarin.Forms because things just stopp working....
Comment 19 Pete Schmitz 2017-09-28 20:28:51 UTC

That's odd. Our app was affected by this bug with previous versions of 2.4, but since we've updated to stable ( earlier today, our listviews (with and without context actions) function correctly now.

Granted, I've only thoroughly tested with a Nexus 6 so far.

I'd recommend doing a full clean of your bin/obj folders, and double check that you're targeting the latest stable on both pcl and android. I remember the former was something that cleared up migration issues for us.
Comment 20 Valonk 2017-09-29 07:16:10 UTC
Thanks for the suggestions but i did try those things before posting here. I only post here if I don't have any  possibilities left.
Comment 21 Kirill Kostrov 2018-04-18 15:10:20 UTC
It look like this one reappears in 2.5.1
Should I create new bug?
Comment 22 David Ortinau [MSFT] 2018-04-18 16:43:02 UTC
@Kirill, yes please open a new report on GitHub for us. https://github.com/xamarin/Xamarin.Forms/issues/new