Bug 35026 - Layout cycle detected. Layout could not complete when re-ordering ItemSource on ListView
Summary: Layout cycle detected. Layout could not complete when re-ordering ItemSource ...
Alias: None
Product: Forms
Classification: Xamarin
Component: Windows ()
Version: 1.5.0
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2015-10-18 19:05 UTC by Shane
Modified: 2016-04-13 18:49 UTC (History)
11 users (show)

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

Recreate layout cycle error (336.49 KB, application/x-zip-compressed)
2015-10-18 19:10 UTC, Shane

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 Shane 2015-10-18 19:05:42 UTC
The attached sample includes a WINRT project and a WIN8.1 SL project... When you click the "SWITCH" the first time it loads the list.. Clicking it a second time removes one of the groups from the end of the list and inserts it at the front of the list.  On WINRT this works fine and everything changes places. If you run the WIN81 SL project it crashes with a layout cycle detected error.

On the ViewCell if you set it to something and then set all the children HeightRequests to something you won't get an error on WIN 81 SL And it all just works correctly

=== Xamarin Studio ===

Version 5.9.7 (build 22)
Installation UUID: 5f3e1f3d-a9ab-4075-8548-c0cc8f9cf6e1
	Microsoft .NET 4.0.30319.42000
	GTK+ 2.24.22 (MS-Windows theme)
	GTK# 2.12.26

=== Xamarin.Android ===

Version: 5.1.7 (Business Edition)
Android SDK: H:\SDKs\android-sdk
	Supported Android versions:
		2.3   (API level 10)
		4.0.3 (API level 15)
		4.1   (API level 16)
		4.2   (API level 17)
		4.4   (API level 19)
		5.0   (API level 21)
		5.1   (API level 22)
Java SDK: C:\Program Files (x86)\Java\jdk1.7.0_55
java version "1.7.0_55"
Java(TM) SE Runtime Environment (build 1.7.0_55-b13)
Java HotSpot(TM) Client VM (build 24.55-b03, mixed mode, sharing)

=== Xamarin Android Player ===

Version: 0.4.4
Location: C:\Program Files\Xamarin Android Player\DeviceManager.exe

=== Build Information ===

Release ID: 509070022
Git revision: 6bd1f169df44ca96addf8a035316c535a4fa46fa
Build date: 2015-09-30 10:13:51-04
Xamarin addins: 1c3e5c0859bdfec0ecd481a57ad6c03bc22f5536

=== Operating System ===

Windows 6.2.9200.0 (64-bit)
Comment 1 Shane 2015-10-18 19:10:08 UTC
Created attachment 13429 [details]
Recreate layout cycle error

The error seems a little edge case also... In the attached sample I typed out the details in the LABEL at the top of the screen and then it stopped giving me the error... So I shrunk the amount of text in that label and then it started failing again
Comment 2 John Hardman 2015-12-04 20:51:25 UTC
I am getting this same exception when I hit the Back button to navigate from a page to the previous page. Will investigate further, but added myself to CC list here.
Comment 3 Valdimar 2015-12-22 14:52:15 UTC
Same here. Worked fine with Xamarin forms 1.5 but when updated to forms 2.0 it crashed, and only when navigating back to previous page.
My ItemsSource is no more than 30 items with a DataTemplate of only a grid, few labels and one image, so that should not be a problem memory or processing wise.

To sum it up, here's my specs:

Xamarin Forms (nuget:
Windows Phone Silverlight 8.1

furthermore there seems to be more people expearancing this:
Comment 4 Harikrishnan 2015-12-23 09:29:38 UTC
Hi Team,
Seems a lot of people facing the same problem. I do face this in my use case which is a DataGrid view to display labels in rows and columns format. 

The forum link specified by @Valdimar is mine. 

I have also reported this in a seperate bug thread. 

But Xamarin does not seem to update anything on this about when this will be fixed. At present am totally stuck and frustrated as this avoids in updating to the latest nugets. Whereas my customers prefer to update to the latest forms version.

Updating only the samples in the customer side leads to a Method missing exception as there seems to be some changes in Xamarin.Forms.ImageSource class which is getting resolved only if I update my source to latest. This is making me neither to update, nor to downgrade leaving me clueless.

I would rather prefer to escalate this if there were an option for it. Hope Xamarin understands the seriousness of this issue and fixes it soon.
Comment 5 Shane 2016-01-31 20:35:56 UTC
Seeing issue on UWP with  "Xamarin.Forms": ""

As a workaround you can null out the ItemSource on the ListView. Perform the sort or changes. Then re-assign the data to ItemSource... In my case I was having an issue when navigating away from the view containing the ListView to an "add/delete" view. Then navigating back to the View with the ListView... So currently I set the ItemSource to Null when navigating away... Then when I navigate back to the ListView, I process any changes I need to on the Source. Then assign it back to the ListView.ItemSource ... For now this lets me work around the exception
Comment 6 Samantha Houts [MSFT] 2016-04-13 18:49:52 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