ObservableCollection.Remove method is throwing ArgumentOutofRange Exception for Xamarin.ios

Manishk_Optimus 1 Reputation point
2022-06-13T16:11:44.17+00:00

The mentioned code is a part of the custom control that we have written. While removing the items from the collection view we are getting the System.ArgumentOutofRange Exception with message Index was out of range, Must be a non-negative and less than the size of collection on the iOS platform. The same code is working fine with the UWP and Android platform

                        _observableCollectionObj.Remove(data);  

Once I am writing the above-mentioned line inside the Device.BeginInvocationOnMainThread block then everything is working fine.

I am not sure what is the reason behind this behavior and why is it working fine with Windows and Android

Developer technologies | .NET | Xamarin
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.