I am just starting with the Telerik Xamarin controls and the documentation uses a single observable collection to display and group data in the listview control. My application uses an observable collection containing the data for a driver's itinerary for multiple days which in turn contain an observable collection of jobs for each day.
Is it possible to bind the group headers to the "runs" collection and the item template to the "jobs" collection?
4 Answers, 1 is accepted
Thank you for your interest in Telerik UI for Xamarin.
It seems from the description that you have hierarchical data and the most suitable component for visualizing such type of data is RadTreeView. You could customize the look & feel of the TreeView items by creating a custom ItemTemplate as well as through defining ItemStyle/ ItemStyleSelector.
I've attached a sample example following the described scenario to show you how binding would work, please download it and give it a try.
RadListView, on the other hand, is used to visualize a list of items, so the grouping is executed per concrete criteria of these items. With ListView the described scenario could be achieved with nested ListView control inside the item template of the root ListView. Still, I would definitely recommend you try the approach with TreeView.
Let me know if you have any additional questions on this.
Thanks for that. I refactored my code to use the TreeView control but unfortunately I ran into some issues with it. I modified my page as follows;
The code to populate the models is;
And the classes are;
When I run the application crashes with the error "System.NullReferenceException: 'Object reference not set to an instance of an object.'"
I i modify the page to use the following code the page displays a single record as expected;
Thank you for sending the code.
I've managed to reproduce it and the reason is that the Jobs collection inside the DriverRunVm class does not have a setter, hence ItemsSourcePath of the TreeViewDescriptor cannot be applied. Please change it like this:
Give this a try and let me know how it goes.
That worked - thanks for your help :)