Bug 33114 - Clearing or reassigning ListView.ItemsSource causes an exception
Summary: Clearing or reassigning ListView.ItemsSource causes an exception
Alias: None
Product: Forms
Classification: Xamarin
Component: Windows ()
Version: 1.4.4
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Rui Marinho
Depends on:
Reported: 2015-08-14 14:08 UTC by Ross Pace
Modified: 2015-11-24 09:45 UTC (History)
4 users (show)

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

Sample project that demonstrates bug (159.73 KB, application/octet-stream)
2015-08-14 14:11 UTC, Ross Pace
Project to demonstrate all exception (7.80 MB, application/x-zip-compressed)
2015-11-11 14:00 UTC, michelcedric18

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 Ross Pace 2015-08-14 14:08:06 UTC
There appears to be a bug in the ListView control for Windows Store apps. If you try to change the ItemsSource after it is loaded it throws an exception. The same exception is thrown if I initially assign an ObservableCollection and use its Clear() function. I can use the Add() method successfully. It seems to only affect removing items. I've attached a sample project that demonstrates the error.

This collection cannot work with indices larger than Int32.MaxValue - 1 (0x7FFFFFFF - 1). Parameter name: index

at System.Runtime.InteropServices.WindowsRuntime.ListToBindableVectorAdapter.EnsureIndexInt32(UInt32 index, Int32 listCapacity)
 at System.Runtime.InteropServices.WindowsRuntime.ListToBindableVectorAdapter.GetAt(UInt32 index)
 at Xamarin.Forms.TemplatedItemsList`2.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
 at Xamarin.Forms.TemplatedItemsList`2.OnProxyCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e, Boolean fixWindows)
 at Xamarin.Forms.TemplatedItemsList`2.OnItemsSourceChanged(Boolean fromGrouping)
 at Xamarin.Forms.TemplatedItemsList`2.BindableOnPropertyChanged(Object sender, PropertyChangedEventArgs e)
 at System.ComponentModel.PropertyChangedEventHandler.Invoke(Object sender, PropertyChangedEventArgs e)
 at Xamarin.Forms.BindableObject.OnPropertyChanged(String propertyName)
 at Xamarin.Forms.BindableObject.SetValueActual(BindableProperty property, BindablePropertyContext context, Object value, Boolean currentlyApplying, SetValueFlags attributes, Boolean silent)
 at Xamarin.Forms.BindableObject.SetValueCore(BindableProperty property, Object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes)
 at Xamarin.Forms.BindableObject.SetValue(BindableProperty property, Object value, Boolean fromStyle, Boolean checkAccess)
 at Xamarin.Forms.ItemsView`1.set_ItemsSource(IEnumerable value)
 at ClassLibrary1.MyPage.<>c__DisplayClass0_0.<.ctor>b__0(Object sender, EventArgs e)
 at Xamarin.Forms.Button.Xamarin.Forms.IButtonController.SendClicked()
 at Xamarin.Forms.Platform.WinRT.ButtonRenderer.OnButtonClick(Object sender, RoutedEventArgs e)
Comment 1 Ross Pace 2015-08-14 14:11:57 UTC
Created attachment 12508 [details]
Sample project that demonstrates bug
Comment 2 Paul DiPietro [MSFT] 2015-08-23 19:51:28 UTC
I ran the sample project and am able to reproduce the crash as you're describing.
Comment 3 michelcedric18 2015-11-10 08:59:29 UTC
I have the same bug , when this bug will fix?
Comment 4 michelcedric18 2015-11-11 13:50:33 UTC
More detail available here :
Comment 5 michelcedric18 2015-11-11 14:00:41 UTC
Created attachment 13781 [details]
Project to demonstrate all exception
Comment 6 Rui Marinho 2015-11-16 17:14:47 UTC
Should be fixed in 1.5.2-pre3
Comment 7 michelcedric18 2015-11-18 06:30:11 UTC
I tried and the bug is not fixed :(
Comment 8 Rui Marinho 2015-11-18 06:46:27 UTC
Sorry this didn't get into 2.0, will be in the next release 2.0.1-pre1