Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ObservableRangeCollection<T>.ReplaceRange not recognized by Xamarin.Forms CollectionView #39

Closed
xamadev opened this issue Apr 2, 2019 · 2 comments

Comments

@xamadev
Copy link

xamadev commented Apr 2, 2019

Got a Xamarin.Forms CollectionView whose ItemsSource is an ObservableRangeCollection. Items are loaded asynchronously at page appearing. The ViewModel replaces existing items and adds new items to the collection by calling the ReplaceRange. The CollectionView somehow doesn't notice data change and nothing is displayed. Applying one of the following changes does show the items.

Workaround 1: Call ObservableRangeCollection.Clear and afterwards ObservableRangeCollection.AddRange

Workaround 2: Use ObservableCollection, call Clear and add items in a foreach loop using the Add method.

Reproduction Link:
https://github.com/xamadev/ObservableRangeCollectionError
Tested on iPhone simulator only

Thanks to @jamesmontemagno for the great helperclasses!

@jamesmontemagno
Copy link
Owner

I would file a bug on Xamarin.Forms as it probably doesn't respect the Reset command.

@pfedotovsky
Copy link

Both workarounds doesn't work for me - I get

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).

Any ideas how to fix it?

@xamadev xamadev closed this as completed Jun 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants