Hello,
I am using ListViewLoadOnDemandCollection https://docs.telerik.com/devtools/xamarin/controls/listview/listview-features-load-on-demand
at Manual Mode
When you click "Load More Items" listing 20 items.
how can ı do list first 20 items automatic when we open page?
and after listing first 20 items if you want more click "Load More Items"
5 Answers, 1 is accepted
I solved this problem but had new one.
on Android working very well but on iOS;
when loading page first time its working nice after navigated another page, coming back and click "Load More Items" then app crashes.
here is trigger code
this.Source = new ListViewLoadOnDemandCollection((cancelationToken) =>
{
lodTriggerCount++;
try
{
var items = new List<String>();
comings = somefunction();
foreach (var myString in comings )
{
items.Add(myString );
}
//
return items;
}
catch
{
return null;
}
});
##on Debug give object null reference exception(appDelegate.cs)
Thank you for sharing the code. Unfortunately, it is not enough information for me to reproduce the problem. There are a lot of factors involved with a Xamarin application, especially one that leads to a plain Null Reference Exception.
If can you put together a simple two-page application that reproduces the issue, I will be able to directly debug it and provide you with a definitive solution.
To give you some ideas to start debugging, put a breakpoint at the top of every method and slowly step through each line until you find the object reference that is null.
Regards,
Lance | Technical Support Engineer, Principal
Progress Telerik
Hello Lance,
Thank you for answer. How can I clear source(ListViewLoadOnDemandCollection)? if source count =0 source.clear() work nice but source.count >0 clear crashes.(its working nice on android. can you test it on ios) and problem at my second post ı debugged it and it give null reference here that ı showed.
this.Source = new ListViewLoadOnDemandCollection((cancelationToken) =>
{
...codes
});// crashing here
* when debugging codes which in trigger nice work till last line but "});" that i showed return null reference after navigated from another tab and click "Load More Items".My guess, if i can clear source problem will fixed when navigated page,But on ios ı cannot clear source.How can I do that?
Thank you
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.Clear();
and this:
if
(Source.Count > 0)
{
Source.Clear();
}
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:
if
(Source?.Count > 0)
{
Source.Clear();
}
Regular ObservableCollection
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.
Further Investigation
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 locally
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.
Regards,
Lance | Technical Support Engineer, Principal
Progress Telerik
Lance Thank you lot.
I found this https://www.telerik.com/forums/radlistview-renderer-throws-nullreferenceexception-on-device-but-not-simulator
and https://feedback.telerik.com/xamarin/1366334-listview-ios-exception-when-rebining-itemssource-after-navigation
this is bug in telerik.Fixed 2018 R2.
I updated telerik and its fixed thank you