RadListView Throws ArgumentOutOfRange Exception When Setting Item In ObservableCollection

3 posts, 0 answers
  1. Kyle
    Kyle avatar
    19 posts
    Member since:
    Jan 2011

    Posted 22 Mar Link to this post

    Telerik Support,

    It seems when you have an ObservableCollection set as the ItemsSource of a RadListView, the RadListView does not like when you set an item in the ObservableCollection using the index of the item.

     

    ex. 

    ObCollection[i] = newObject;

    I get the following exception:

    at Android.Runtime.JavaList.get_Item (System.Int32 index) [0x00013] in /Users/builder/data/lanes/4009/3a62f1ea/source/xamarin-android/src/Mono.Android/Android.Runtime/JavaList.cs:115
    at Telerik.XamarinForms.DataControlsRenderer.Android.ListViewAdapter.UpdateCollectionCore (Telerik.XamarinForms.DataControls.RadListView sourceOwner, Com.Telerik.Widget.List.RadListView targetOwner, System.String propertyName, System.Collections.Specialized.NotifyCollectionChangedEventArgs args) [0x001bd] in <65c6ed5e8fb14b688091ad2fdaa0480e>:0
    at Telerik.XamarinForms.Common.FacadeAdapterBase`2[S,T].UpdateCollection (System.Object sourceOwner, System.Object targetOwner, System.String propertyName, System.Collections.Specialized.NotifyCollectionChangedEventArgs args) [0x00000] in <b09df7d4d5e74454b9482f9e64875b96>:0
    at Telerik.XamarinForms.Common.XamarinToNativeControlExtensions.UpdateCollection[T,K] (T nativeElement, K xfЕlement, System.String propertyName, System.Collections.Specialized.NotifyCollectionChangedEventArgs args) [0x00028] in <b09df7d4d5e74454b9482f9e64875b96>:0
    at Telerik.XamarinForms.DataControlsRenderer.Android.ListViewRenderer.ItemsSource_CollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00011] in <65c6ed5e8fb14b688091ad2fdaa0480e>:0
    at Telerik.XamarinForms.DataControls.RadListView.OnItemsSourceCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x0000a] in <f0d98fc8921f4f449b0a58a0baeb50d3>:0
    at System.Collections.ObjectModel.ObservableCollection`1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00012] in /Users/builder/data/lanes/4009/3a62f1ea/source/mono/mcs/class/referencesource/System/compmod/system/collections/objectmodel/observablecollection.cs:288
    at AlertPSS.Data.APSSObservableItemCollection`1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00000] in <433f2a6adeaf4b85b51b3da650694a41>:0
    at System.Collections.ObjectModel.ObservableCollection`1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedAction action, System.Object oldItem, System.Object newItem, System.Int32 index) [0x00000] in /Users/builder/data/lanes/4009/3a62f1ea/source/mono/mcs/class/referencesource/System/compmod/system/collections/objectmodel/observablecollection.cs:367
    at System.Collections.ObjectModel.ObservableCollection`1[T].SetItem (System.Int32 index, T item) [0x00021] in /Users/builder/data/lanes/4009/3a62f1ea/source/mono/mcs/class/referencesource/System/compmod/system/collections/objectmodel/observablecollection.cs:233
    at System.Collections.ObjectModel.Collection`1[T].set_Item (System.Int32 index, T value) [0x00034] in /Users/builder/data/lanes/4009/3a62f1ea/source/mono/mcs/class/referencesource/mscorlib/system/collections/objectmodel/collection.cs:57
    at AlertPSS.Transcend.AsyncReturns.AddFilteredIncident (AlertPSS.Client.Client.ClientInc inc, System.Boolean isUpdate, System.Boolean isInitial, System.Boolean isPulldown) [0x0060c] in C:\Users\kgrub\Documents\Visual Studio 2015\Projects\AlertPSS.Transcend\AlertPSS.Transcend\AsyncReturns.cs:1693
    at AlertPSS.Transcend.AsyncReturns+<>c__DisplayClass30_0.<ProcessIncidentUpdate>b__0 () [0x0075a] in C:\Users\kgrub\Documents\Visual Studio 2015\Projects\AlertPSS.Transcend\AlertPSS.Transcend\AsyncReturns.cs:1269

     

    This convention is used in WPF/Silverlight to keep a bound collection control ordered correctly instead of removing the item and re-adding it.  Should I not be doing it this way in Xamarin?

     

    Please let me know if you need any further information, I am using Telerik For Xamarin 2017 R1 (2017.1.10120.233).

     

    Thanks!

  2. Lance | Tech Support Engineer, Sr.
    Admin
    Lance | Tech Support Engineer, Sr. avatar
    465 posts

    Posted 23 Mar Link to this post

    Hi Kyle,

    I am not able to reproduce this on my end, take a look at my attached demo.

    Click the button and the 2nd item in the RadListView is updated using the same approach you use; the item at the 2nd index in the ObservableCollection is updated with a new object at that index (see the button click handler).

    At this time it doesn't appear to be related to the RadListView. In your app, if you swap the RadListView with a plain Xamarin Forms ListView, does it still occur?

    If you find that it only occurs with the RadList view, can you update the attached demo so that it replicates the problem and send it back to us? That allow us to investigate further.

    Regards,
    Lance | Tech Support Engineer, Sr.
    Telerik by Progress
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. Kyle
    Kyle avatar
    19 posts
    Member since:
    Jan 2011

    Posted 31 Mar in reply to Lance | Tech Support Engineer, Sr. Link to this post

    Thank you for the quick reply, and sorry it took me so long to get back to you.  I commented this out for now, but I will do some testing and see if I can reproduce it in an isolated environment and whether or not it's strictly related to the RadListView or also affects Xamarin.Forms ListView.
Back to Top