I've encountered a situation that I think the community should know about as it took me a while to figure out the issue.
I am in the process of creating an app based upon the hybrid example in the docs.
The app has a view model that has a property of type bindableCollection. This collection is populated OnViewLoaded via an async task that calls a web service.
On the initial load of the view model, the process works as expected. I then click to a different 'part' of the application (ex: orders) and then click back to the 'part' of the application that has this view model.
The application then throws the ArgumentOutOfRangeException inside the BindableCollection.cs class in the InsertItemBase method, with the index parameter being outside the range of the actual collection size.
The issue appears to be as follows
1) the 'load' method is called within a System.Threading.Task and it calls two methods on the BindableCollection in succession
2) internal to each BindableCollection method, it calls Execute.OnUIThread which does a BeginInvoke on the dispatcher
3) the actual 'Clear' method (inside the beginInvoke) has not yet been executed by the time the prop.AddRange method is started.
* the AddRange method still thinks that the count is > 0 and tries to add items to the end of the underlying list (again - thru the Dispatcher BeginInvoke
4) the actual 'Clear' method inside the beginInvoke then proceeds and clears the underlying collection
5) the actual 'AddRange' method inside the beginInvoke then proceeds and fails as it tries to add an item with an invalid index.
The way that I worked around the issue was to change the 'load' method to have the bindableCollection methods inside an Execute.OnUIThread
Execute.OnUIThread(() => prop.Clear; prop.AddRange(...));
Hopes this helps others who might encounter this situation.