Bug 23778 - ObservableCollection in ListView gets Index out of range when removing item
Summary: ObservableCollection in ListView gets Index out of range when removing item
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.3.0
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-10-13 10:02 UTC by Paul Charlton
Modified: 2014-10-20 21:56 UTC (History)
5 users (show)

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


Attachments
cs file as example (2.56 KB, text/plain)
2014-10-13 10:02 UTC, Paul Charlton
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 FIXED

Description Paul Charlton 2014-10-13 10:02:28 UTC
Created attachment 8390 [details]
cs file as example

I have a list view that uses grouping and is bound to an ObservableCollection (source) of ObservableCollections (groups).  When one of the groups is removed (source.Remove()) from the source an ArgumentOutOfRangeException is fired.  This exception only occurs if this is the last group in the source.

I've attached an example .cs file and the exception trace is below.

10-13 05:01:49.546 I/MonoDroid(15218): System.ArgumentOutOfRangeException: Argument is out of range.
10-13 05:01:49.546 I/MonoDroid(15218): Parameter name: index
10-13 05:01:49.546 I/MonoDroid(15218): at System.Collections.Generic.List`1<object>.get_Item (int) <0x0007c>
10-13 05:01:49.546 I/MonoDroid(15218): at Cadenza.Collections.OrderedDictionary`2<object, Xamarin.Forms.TemplatedItemsList`2<Xamarin.Forms.ItemsView`1<Xamarin.Forms.Cell>, Xamarin.Forms.Cell>>.get_Item (int) <0x00063>
10-13 05:01:49.546 I/MonoDroid(15218): at Xamarin.Forms.TemplatedItemsList`2<Xamarin.Forms.ItemsView`1<Xamarin.Forms.Cell>, Xamarin.Forms.Cell>.GetGroup (int) <0x000cf>
10-13 05:01:49.546 I/MonoDroid(15218): at Xamarin.Forms.Platform.Android.ListViewAdapter.OnCollectionChanged (object,System.Collections.Specialized.NotifyCollectionChangedEventArgs) <IL 0x00067, 0x002ff>
10-13 05:01:49.546 I/MonoDroid(15218): at (wrapper delegate-invoke) <Module>.invoke_void_object_NotifyCollectionChangedEventArgs (object,System.Collections.Specialized.NotifyCollectionChangedEventArgs) <IL 0x00044, 0x0009f>
10-13 05:01:49.546 I/MonoDroid(15218): at Xamarin.Forms.TemplatedItemsList`2<Xamarin.Forms.ItemsView`1<Xamarin.Forms.Cell>, Xamarin.Forms.Cell>.OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs) <0x00097>
10-13 05:01:49.554 I/MonoDroid(15218): at Xamarin.Forms.TemplatedItemsList`2<Xamarin.Forms.ItemsView`1<Xamarin.Forms.Cell>, Xamarin.Forms.Cell>.OnCollectionChangedGrouped (System.Collections.Specialized.NotifyCollectionChangedEventArgs) <0x00c6f>
10-13 05:01:49.554 I/MonoDroid(15218): at Xamarin.Forms.TemplatedItemsList`2<Xamarin.Forms.ItemsView`1<Xamarin.Forms.Cell>, Xamarin.Forms.Cell>.OnProxyCollectionChanged (object,System.Collections.Specialized.NotifyCollectionChangedEventArgs,bool) <0x0012b>
10-13 05:01:49.554 I/MonoDroid(15218): at Xamarin.Forms.TemplatedItemsList`2<Xamarin.Forms.ItemsView`1<Xamarin.Forms.Cell>, Xamarin.Forms.Cell>.OnProxyCollectionChanged (object,System.Collections.Specialized.NotifyCollectionChangedEventArgs) <0x00057>
10-13 05:01:49.554 I/MonoDroid(15218): at Xamarin.Forms.ListProxy.OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs) <IL 0x0000d, 0x00097>
10-13 05:01:49.562 I/MonoDroid(15218): at Xamarin.Forms.ListProxy/<>c__DisplayClassc.<OnCollectionChanged>b__8 () <IL 0x0001f, 0x00077>
10-13 05:01:49.562 I/MonoDroid(15218): at Xamarin.Forms.ListProxy.OnCollectionChanged (object,System.Collections.Specialized.NotifyCollectionChangedEventArgs) <IL 0x000b4, 0x005ef>
10-13 05:01:49.562 I/MonoDroid(15218): at System.Collections.ObjectModel.ObservableCollection`1<MobileShared.Grouping`2<string, string>>.OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs) <0x000f7>
10-13 05:01:49.562 I/MonoDroid(15218): at System.Collections.ObjectModel.ObservableCollection`1<MobileShared.Grouping`2<string, string>>.RemoveItem (int) <0x0014f>
10-13 05:01:49.562 I/MonoDroid(15218): at System.Collections.ObjectModel.Collection`1<MobileShared.Grouping`2<string, string>>.Remove (MobileShared.Grouping`2<string, string>) <0x000f3>
10-13 05:01:49.562 I/MonoDroid(15218): at MobileShared.PlayPage2/<>c__DisplayClass8.<.ctor>b__7 (object,System.EventArgs) [0x00016] in c:\visual studio\Sandbox\MobilePlayPen\MobileShared\MobileShared\PlayPage2.cs:39
10-13 05:01:49.562 I/MonoDroid(15218): at Xamarin.Forms.Button.SendClicked () <IL 0x00027, 0x0014f>
10-13 05:01:49.570 I/MonoDroid(15218): at Xamarin.Forms.Platform.Android.ButtonRenderer/ButtonClickListener.OnClick (Android.Views.View) <IL 0x00015, 0x0010b>
10-13 05:01:49.570 I/MonoDroid(15218): at Android.Views.View/IOnClickListenerInvoker.n_OnClick_Landroid_view_View_ (intptr,intptr,intptr) [0x00011] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.18-series/3b7ef0a7/source/monodroid/src/Mono.Android/platforms/android-19/src/generated/Android.Views.View.cs:1840
10-13 05:01:49.570 I/MonoDroid(15218): at (wrapper dynamic-method) object.1e40d02c-4c30-4548-84d5-2fa72bcde4a4 (intptr,intptr,intptr) <IL 0x00017, 0x00043>
10-13 05:01:49.585 I/dalvikvm(15218): Could not find method java.lang.Throwable.<init>, referenced from method android.runtime.JavaProxyThrowable.<init>
10-13 05:01:49.585 W/dalvikvm(15218): VFY: unable to resolve direct method 5581: Ljava/lang/Throwable;.<init> (Ljava/lang/String;Ljava/lang/Throwable;ZZ)V
10-13 05:01:49.585 D/dalvikvm(15218): VFY: replacing opcode 0x70 at 0x0000
An unhandled exception occured.

10-13 05:01:50.726 E/mono    (15218): 
10-13 05:01:50.726 E/mono    (15218): Unhandled Exception:
10-13 05:01:50.726 E/mono    (15218): System.ArgumentOutOfRangeException: Argument is out of range.
10-13 05:01:50.726 E/mono    (15218): Parameter name: index
10-13 05:01:50.726 E/mono    (15218):   at System.Collections.Generic.List`1[System.Object].get_Item (Int32 index) [0x00000] in <filename unknown>:0 
10-13 05:01:50.726 E/mono    (15218):   at Cadenza.Collections.OrderedDictionary`2[System.Object,Xamarin.Forms.TemplatedItemsList`2[Xamarin.Forms.ItemsView`1[Xamarin.Forms.Cell],Xamarin.Forms.Cell]].get_Item (Int32 index) [0x00000] in <filename unknown>:0 
10-13 05:01:50.726 E/mono    (15218):   at Xamarin.Forms.TemplatedItemsList`2[Xamarin.Forms.ItemsView`1[Xamarin.Forms.Cell],Xamarin.Forms.Cell].GetGroup (Int32 index) [0x00000] in <filename unknown>:0 
10-13 05:01:50.726 E/mono    (15218):   at Xamarin.Forms.Platform.Android.ListViewAdapter.OnCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00000] in <filename unknown>:0 
10-13 05:01:50.726 E/mono    (15218):   at (wrapper delegate-invoke) <Module>:invoke_void_object_NotifyCollectionChangedEventArgs (object,System.Collections.Specialized.NotifyCollectionChangedEventArgs)
10-13 05:01:50.726 E/mono-rt10-13 05:01:50.726 E/mono    (15218):   at Xamarin.Forms.TemplatedItemsList`2[Xamarin.Forms.ItemsView`1[Xamarin.Forms.Cell],Xamarin.Forms.Cell].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00000] in <filename unknown>:0 
10-13 05:01:50.726 E/mono    (15218):   at Xamarin.Forms.TemplatedItemsList`2[Xamarin.Forms.ItemsView`1[Xamarin.Forms.Cell],Xamarin.Forms.Cell].OnCollectionChangedGrouped (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00000] in <filename unknown>:0 
10-13 05:01:50.726 E/mono    (15218):   at Xamarin.Forms.TemplatedItemsList`2[Xamarin.Forms.ItemsView`1[Xamarin.Forms.Cell],Xamarin.Forms.Cell].OnProxyCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e, Boolean fixWindows) [0x00000] in <filename unknown>:0 
10-13 05:01:50.726 E/mono    (15218):   at Xamarin.Forms.TemplatedItemsList`2[Xamarin.Forms.ItemsView`1[Xamarin.Forms.Cell],Xamarin.Forms.Cell].OnProxyCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00000] in <filename unknown>:0 
10-13 05:01:50.726 E/mono    (15218):   at Xamarin.Forms.ListProxy.OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00000] in <filename unknown>:0 
10-13 05:01:50.726 E/mono    (15218):   at Xamarin.Forms.ListProxy+<>c__DisplayClassc.<OnCollectionChanged>b__8 () [0x00000] in <filename unknown>:0 
10-13 05:01:50.726 E/mono    (15218):   at Xamarin.Forms.ListProxy.OnCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00000] in <filename unknown>:0 
10-13 05:01:50.726 E/mono    (15218):   at System.Collections.ObjectModel.ObservableCollection`1[MobileShared.Grouping`2[System.String,System.String]].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00000] in <filename unknown>:0 
10-13 05:01:50.726 E/mono    (15218):   at System.Collections.ObjectModel.ObservableCollection`1[MobileShared.Grouping`2[System.String,System.String]].RemoveItem (Int32 index) [0x00000] in <filename unknown>:0 
10-13 05:01:50.726 E/mono    (15218):   at System.Collections.ObjectModel.Collection`1[MobileShared.Grouping`2[System.String,System.String]].Remove (MobileShared.Grouping`2 item) [0x00000] in <filename unknown>:0 
10-13 05:01:50.726 E/mono    (15218):   at MobileShared.PlayPage2+<>c__DisplayClass8.<.ctor>b__7 (System.Object sender, System.EventArgs args) [0x00016] in c:\visual studio\Sandbox\MobilePlayPen\MobileShared\MobileShared\PlayPage2.cs:39 
10-13 05:01:50.726 E/mono    (15218):   at Xamarin.Forms.Button.SendClicked () [0x00000] in <filename unknown>:0 
10-13 05:01:50.726 E/mono    (15218):   at Xamarin.Forms.Platform.Android.ButtonRenderer+ButtonClickListener.OnClick (Android.Views.View v) [0x00000] in <filename unknown>:0 
10-13 05:01:50.726 E/mono    (15218):   at Android.Views.View+IOnClickListenerInvoker.n_OnClick_Landroid_view_View_ (IntPtr jnienv, IntPtr native__this, IntPtr native_v) [0x00011] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.18-series/3b7ef0a7/source/monodroid/src/Mono.Android/platforms/android-19/src/generated/Android.Views.View.cs:1840 
10-13 05:01:50.726 E/mono    (15218):   at (wrapper dynamic-method) object:1e40d02c-4c30-4548-84d5-2fa72bcde4a4 (intptr,intptr,intptr)
10-13 05:01:50.726 E/mono-rt (15218): [ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentOutOfRangeException: Argument is out of range.
10-13 05:01:50.726 E/mono-rt (15218): Parameter name: index
10-13 05:01:50.726 E/mono-rt (15218):   at System.Collections.Generic.List`1[System.Object].get_Item (Int32 index) [0x00000] in <filename unknown>:0 
10-13 05:01:50.726 E/mono-rt (15218):   at Cadenza.Collections.OrderedDictionary`2[System.Object,Xamarin.Forms.TemplatedItemsList`2[Xamarin.Forms.ItemsView`1[Xamarin.Forms.Cell],Xamarin.Forms.Cell]].get_Item (Int32 index) [0x00000] in <filename unknown>:0 
10-13 05:01:50.726 E/mono-rt (15218):   at Xamarin.Forms.TemplatedItemsList`2[Xamarin.Forms.ItemsView`1[Xamarin.Forms.Cell],Xamarin.Forms.Cell].GetGroup (Int32 index) [0x00000] in <filename unknown>:0 
10-13 05:01:50.726 E/mono-rt (15218):   at Xamarin.Forms.Platform.Android.ListViewAdapter.OnCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00000] in <filename unknown>:0 
10-13 05:01:50.726 E/mono-rt (15218):   at (wrapper delegate-invoke) <Module>:invoke_void_object_NotifyCollectionChangedEventArgs (object,System.Collections.Specialized.NotifyCollectionChangedEventArgs)
10-13 05:01:50.726 E/mono-rt (15218):   at Xamarin.Forms.TemplatedItemsList`2[Xamarin.Forms.ItemsView`1[Xamarin.Forms.Cell],Xamarin.Forms.Cell].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00000] in <filename unknown>:0 
10-13 05:01:50.726 E/mono-rt (15218):   at Xamarin.Forms.TemplatedItemsList`2[Xamarin.Forms.ItemsView`1[Xamarin.Forms.Cell],Xamarin.Forms.Cell].OnCollectionChangedGrouped (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00000] in <filename unknown>:0 
10-13 05:01:50.726 E/mono-rt (15218):   at Xamarin.Forms.TemplatedItemsList`2[Xamarin.Forms.ItemsView`1[Xamarin.Forms.Cell],Xamarin.Forms.Cell].OnProxyCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e, Boolean fixWindows) [0x00000] in <filename unknown>:0 
10-13 05:01:50.726 E/mono-rt (15218):   at Xamarin.Forms.TemplatedItemsList`2[Xamarin.Forms.ItemsView`1[Xamarin.Forms.Cell],Xamarin.Forms.Cell].OnProxyCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00000] in <filename unknown>:0 
10-13 05:01:50.726 E/mono-rt (15218):   at Xamarin.Forms.ListProxy.OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00000] in <filename unknown>:0 
10-13 05:01:50.726 E/mono-rt (15218):   at Xamarin.Forms.ListProxy+<>c__DisplayClassc.<OnCollectionChanged>b__8 () [0x00000] in <filename unknown>:0 
10-13 05:01:50.726 E/mono-rt (15218):   at Xamarin.Forms.ListProxy.OnCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00000] in <filename unknown>:0 
10-13 05:01:50.726 E/mono-rt (15218):   at System.Collections.ObjectModel.ObservableCollection`1[MobileShared.Grouping`2[System.String,System.String]].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00000] in <filename unknown>:0 
10-13 05:01:50.726 E/mono-rt (15218):   at System.Collections.ObjectModel.ObservableCollection`1[MobileShared.Grouping`2[System.String,System.String]].RemoveItem (Int32 index) [0x00000] in <filename unknown>:0 
10-13 05:01:50.726 E/mono-rt (15218):   at System.Collections.ObjectModel.Collection`1[MobileShared.Grouping`2[System.String,System.String]].Remove (MobileShared.Grouping`2 item) [0x00000] in <filename unknown>:0 
10-13 05:01:50.726 E/mono-rt (15218):   at MobileShared.PlayPage2+<>c__DisplayClass8.<.ctor>b__7 (System.Object sender, System.EventArgs args) [0x00016] in c:\visual studio\Sandbox\MobilePlayPen\MobileShared\MobileShared\PlayPage2.cs:39 
10-13 05:01:50.726 E/mono-rt (15218):   at Xamarin.Forms.Button.SendClicked () [0x00000] in <filename unknown>:0 
10-13 05:01:50.726 E/mono-rt (15218):   at Xamarin.Forms.Platform.Android.ButtonRenderer+ButtonClickListener.OnClick (Android.Views.View v) [0x00000] in <filename unknown>:0 
10-13 05:01:50.726 E/mono-rt (15218):   at Android.Views.View+IOnClickListenerInvoker.n_OnClick_Landroid_view_View_ (IntPtr jnienv, IntPtr native__this, IntPtr native_v) [0x00011] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.18-series/3b7ef0a7/source/monodroid/src/Mono.Android/platforms/android-19/src/generated/Android.Views.View.cs:1840 
10-13 05:01:50.726 E/mono-rt (15218):   at (wrapper dynamic-method) object:1e40d02c-4c30-4548-84d5-2fa72bcde4a4 (intptr,intptr,intptr)
Comment 2 Udham Singh 2014-10-13 11:36:48 UTC
An update to the comment 1 : I have used device Samsung S5(android 4.4.2).
Comment 3 Jason Smith [MSFT] 2014-10-20 21:56:13 UTC
Should be fixed in 1.3.0 final