See issue: https://github.com/jamesmontemagno/mvvm-helpers/issues/39
Xamarin.Forms 3.6.0.264807
Visual Studio 2017 Version 15.9.10
Platforms:
iOS Simulator with iOS 12.1 (iPhone SE)
Not sure if CollectionView
supports ObservableRangeCollection
.
https://github.com/jamesmontemagno/mvvm-helpers
https://gist.github.com/weitzhandler/65ac9113e31d12e697cb58cd92601091
https://forums.xamarin.com/discussion/29925/observablecollection-addrange
Looks like there is an internal ObservableList<T>
with similar functionality.
The same issue with ListView
(for ObservableRangeCollection
from mvvm-helpers), replacing to ObservableCollection - works correctly.
I get the following error while using ObservableCollection with CollectionView
Objective - C exception thrown. Name: NSInternalInconsistencyException Reason: Invalid update: invalid number of items in section 0.The number of items contained in an existing section after the update(13) must be equal to the number of items contained in that section before the update(13), plus or minus the number of items inserted or deleted from that section (13 inserted, 0 deleted) and plus or minus the number of items moved into or out of that section(0 moved in, 0 moved out).
@pfedotovsky This error usually happens (on iOS) when items are NOT being added to the underlying adapter/data source on the main thread.
Seems to work just fine on Android, which is interesting......
Seems to work just fine on Android, which is interesting......
Oh, I see what y'all are talking about now. Yes, Android does a NotifyDataSetChanged on Reset. Looks like I forgot to call ReloadData on iOS. Fix incoming ...
This issue still existed. Could you check again please ?
@Thanghand Which version of Forms are you using?
I am also still having this issue with a collection view. I am using Xamarin.Forms 4.1.0.581479.
Initially the observable collection is empty, then when new data arrives I call Clear and then add the new items.
I have also tried initialising the collection with some items and then calling reset with new items. The initial items display correctly but the new items cause the same error. Here is an Example Repo.
EDIT1: I have tested using the latest pre-release currently available (4.2.0.608146-pre1) and the issue still persists.
Also testing on the latest preview (due to bug in stable for android) and I have the same issue in ios now
4.4.0.991210-pre2
It's still happening on 4.7.0.1080(latest).
Most helpful comment
I am also still having this issue with a collection view. I am using Xamarin.Forms 4.1.0.581479.
Initially the observable collection is empty, then when new data arrives I call Clear and then add the new items.
I have also tried initialising the collection with some items and then calling reset with new items. The initial items display correctly but the new items cause the same error. Here is an Example Repo.
EDIT1: I have tested using the latest pre-release currently available (4.2.0.608146-pre1) and the issue still persists.