I'm still not sure where the problem is from the description of the problem alone. I suspect there are side effects happening depending on the timing of the logic. For example, there is no difference between this:
(Source.Count > 0)
The only thing I can guess is that the Source is null
when the logic attempts to access a property or call Clear. You can prevent this issue by checking for null first:
(Source?.Count > 0)
If this continues to give you difficult, you can use a normal ObservableCollection and use the LoadOnDemand event (via EventToCommandBehavior
) to manage the items in the collection.
In order for me to assist further, I really need to be able to replicate the issue on my side. Then, I can debug it directly and inspect the objects and their values to tell you exactly where the problem is.
Option 1 (fastest option) - Isolate the Problem in a test project
The best option is to just use the File > New Project > Telerik Xamarin UI
project template and replicate the problem in isolation. You'll only need to add a 2nd page and copy in your existing code.
Option 2 - Use my LoadOnDemandCollection Example to replicate the issue
If your application is too large to share or has private information, you can just use my ComicVine LoadOnDemandCollection Demo
to replicate the problem.
1. Clone the ComicVine demo
2. Notice CharactersPage
uses a LoadOnDemandCollection in the ViewModel
3. Replicate the problem you're having in that code and commit it t your cloned copy
4 . Reply back here with a link to your repo and I'll investigate directly
Option 3 - Share all the relevant files from your project
If you zip up all the relevant files; views, viewmodels, data models and any other required classes (behaviors, App.xaml for styles, etc), I can build a demo around it. However, this will take a little longer for me to get back to you with my findings.
Lance | Technical Support Engineer, Principal
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