Bug 46039 - listview ItemSource not updating
Summary: listview ItemSource not updating
Status: RESOLVED INVALID
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.3.2
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-10-27 15:05 UTC by Andrew
Modified: 2017-06-09 17:08 UTC (History)
5 users (show)

Tags: iOS ac
Is this bug a regression?: ---
Last known good build:


Attachments
sample (57.82 KB, application/zip)
2016-10-27 15:06 UTC, Andrew
Details


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:
Status:
RESOLVED INVALID

Description Andrew 2016-10-27 15:05:42 UTC
Xamarin Forms version: 2.3.2.127

Android works as expected. iOS not refreshing ItemSource after update.

Run Sample.

Click "Write Tab"
Click "Write" Button a few times

Go back to the "Log" Tab.  The listview should display items.
Comment 1 Andrew 2016-10-27 15:06:06 UTC
Created attachment 18250 [details]
sample
Comment 2 Andrew 2016-10-27 15:08:54 UTC
The workaround is to add this:  

list.ItemsSource = null;      // first set to null.  should not be needed
list.ItemsSource = App.Log;
Comment 3 adrianknight89 2016-11-01 08:39:00 UTC
I'm not sure why this was confirmed. Was this regression?

The issue is that App.Log is not changing its reference but its content. List<string> has no concept of individual items updating. Use an ObservableCollection instead.

public static ObservableCollection<string> Log;
Comment 4 adrianknight89 2016-11-01 08:41:00 UTC
Actually, since you said Android works, then this is probably a bug. I'll try to look at it again tomorrow.
Comment 5 Andrew 2016-11-01 16:16:23 UTC
I was doing a test and expected it to update like Android without first setting listview.Itemsource = null. I just rebound it on appear.
Comment 6 adrianknight89 2016-11-08 01:32:52 UTC
@Andrew, this does not work for me on AppCompat either. You said it's working on Android, but I can't duplicate it. Perhaps, try uploading a screencast showing us it's working on Android.

As I said earlier, you should use ObservableCollection instead which implements INotifyCollectionChanged and INotifyPropertyChanged.
Comment 7 Paul DiPietro [MSFT] 2017-06-09 17:08:58 UTC
This is not a bug. Using an ObservableCollection lets it function as expected.