Bug 31565 - ListView with custom ViewCells not always showing on Android
Summary: ListView with custom ViewCells not always showing on Android
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.4.3
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2015-07-02 05:01 UTC by Kasper
Modified: 2016-04-10 06:27 UTC (History)
4 users (show)

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

Sample solution (170.47 KB, application/x-gzip)
2015-07-03 08:57 UTC, Kasper

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 Kasper 2015-07-02 05:01:19 UTC
ListView is broken for me on Android when using custom ViewCells. Some of them are not showing up. I can see the binding updating fine, the ViewCells ctor is being called correctly, but not all items are shown on screen.

I have some ListViews that just use TextCell, and these does not cause any trouble for me.

Downgrading to fixes the issue.

I have only tested on Android, since this is what I focus on at the moment.

My ViewCell looks like this:

	public class PickListItemCell : ViewCell {
		private AddressView _addressView = new AddressView();
		private ListViewCheckBox _barcode = new ListViewCheckBox ();

		public PickListItemCell ()
			View = new StackLayout {
				Padding = new Thickness(5),
				Children = {
			_barcode.SetBinding (ListViewCheckBox.DefaultTextProperty, "Barcode.Text");
			_barcode.SetBinding (ListViewCheckBox.CheckedProperty, "Selected", BindingMode.TwoWay);

			_addressView.Name.SetBinding (Label.TextProperty, new Binding ("Address.Name"));
			_addressView.Street.SetBinding (Label.TextProperty, new Binding ("Address.StreetWithHouseNumber"));
			_addressView.Zip.SetBinding (Label.TextProperty, new Binding ("Address.Zip"));
			_addressView.City.SetBinding (Label.TextProperty, new Binding ("Address.City"));

The view model look like this:
	public class PickListItemViewModel : BindableBase, IEquatable<PickListItemViewModel> {
		private IBarcode _barcode;
		public IBarcode Barcode { 
			get { return _barcode; } 
			set{ SetProperty(ref _barcode, value); } 

		Address _address;
		public Address Address {
			get { return _address; }
			set { SetProperty(ref _address, value); }

		bool _selected;
		public bool Selected {
			get { return _selected; }
			set { 
				if (SetProperty(ref _selected, value))

		public event Action<bool> SelectedChanged;

		public MyTask Task { get; set; } // don't raise PropertyChanged event.

		#region IEquatable implementation

		public bool Equals (PickListItemViewModel other)
			return other == null ? false : _barcode.CompareTo (other.Barcode) == 0;


		public override int GetHashCode ()
			return _barcode.Text.GetHashCode ();

Bindable base simply helps with raising property changed events. It is similar to the similar named class from Microsoft.
Comment 1 Parmendra Kumar 2015-07-02 06:48:40 UTC

I have checked this issue with provided sample code in bug description but not able to reproduce this issue.
Could you please provide us a complete sample project so that I can reproduce this issue at my end.

Comment 2 Kasper 2015-07-02 09:05:42 UTC
Since you already converted my code snippets into a standalone project, could you please send the project back to me - then I can build from there.
Comment 3 Parmendra Kumar 2015-07-03 07:03:23 UTC

I have tried to use your provided sample code but I am getting error message for class missing.

Screencast: http://www.screencast.com/t/ooFXheb4ws

Sample code: https://www.dropbox.com/s/r72nc53bzsp8lkc/Forms88.zip?dl=0

Could you please provide us complete sample project so that I can reproduce it at my end.

Comment 4 Kasper 2015-07-03 08:57:55 UTC
Created attachment 11845 [details]
Sample solution

Remember to do a package restore, as I excluded the packages from the bundled solution
Comment 5 Kasper 2015-07-03 09:16:41 UTC

I have downloaded the solution from dropbox.

BTW: May I recommend that you clear all build artifacts from the solution directory and also delete the packages directory, before zipping the solution. This way you can squeeze the zip from 66 MiB to 172 kiB.

I modified the solution to try and make the smallest viable reproduction.

The app simply display a ListView with CustomItemCells derived from ViewCell. A CustomItemCell simply contains a Label wrapped in a stack layout. The Label.TextProperty of the Label is bound to the Text property of a CustomItemViewModel.

The ListView.ItemsSource is simply an ObservableCollection<CustomItemViewModel>.

Whenever the user hits the "Next Table" button, the observable collection is cleared and an infinite sequence of integers are added (firstr 1,2,3,.. then 2,4,6,.. and so on).

The bug is supposed to be that sometimes items are missing when using XF 1.4.3, but not when using 1.4.2. However I must admit I cannot reproduce it currently. I will make a screencast if succeed.
Comment 6 Parmendra Kumar 2015-07-06 08:25:53 UTC
Thanks @Kasper

I have checked this issue with attached sample in comment #4 and observed that If I have scroll up and click on 'Next table' button, ListView is not showing.

Screencast: http://www.screencast.com/t/BDUIvKL45VR

Please check the screencast and let me know are you getting same behavior or I have missed anything.

I am getting same behavior with X.F 1.4.2 and 1.4.3.x

ApplicationOutput: https://gist.github.com/Parmendrak/80e8fec8fcd5efd4e71f

Environment info:

Xamarin Studio  5.9.4 (build 5)
Mono 4.0.2 ((detached/c99aa0c)
Xcode 6.2 (6776)
Xamarin.iOS : (Enterprise Edition)
Xamarin.Android: (Enterprise Edition)
Mac OS X 10.9.4
Comment 7 Jason Smith [MSFT] 2016-04-10 06:27:09 UTC
Thank you for taking the time to submit this report. After reviewing the description of this bug, we believe it no longer affects the current version of Xamarin.Forms. If you are still experiencing the issue after updating your packages, please reopen this report with an attached reproduction.
For your convenience, we have created some reproduction best practices viewable here: https://gist.github.com/jassmith/92405c300e54a01dcc6d

Warm regards,
Xamarin Forms Team