We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Binding to Lists of Lists in XAML

If I have a list of lists object, let's call it MovieCatalogue, and in that list of lists I have a collection of lists that contain Movies that relate to the same genre. 

I want to be able to set the ItemSource of the Rotator to the MovieCatalogue object and then have each page show a ListView of all movies contained within the lists of the object. For example, page one of the rotator would show me all entries of the HorrorList, page two would show all entries of ComedyList and so on.. 

As a bonus, each entry would need to be bound to the title of the movie that is stored in the list. Attached is my current implementation, but it returns an invalid cast exception.

Attachment: movielistrotator_f5b39938.zip

3 Replies

MK Muneesh Kumar G Syncfusion Team July 6, 2019 06:22 AM

Hi Liam, 
 
Greetings from Syncfusion.  
 
We have validated your query and your code snippet, to resolve the reported issue you have to add the ViewCell before the label in listview as like below code snippet. 
 
<rotator:SfRotator  x:Name="ImageRotator"  ItemsSource="{Binding ImageCollection}" DotsBorderColor="Red"   HorizontalOptions="FillAndExpand" 
            VerticalOptions="FillAndExpand">
            <rotator:SfRotator.ItemTemplate>
                <DataTemplate>
                 <ListView  ItemsSource="{Binding ImageList}">
                    <ListView.ItemTemplate>
                                <DataTemplate>
                               <ViewCell>
                                    <Label Text ="{Binding Title}"/>
                                 </ViewCell>
                                </DataTemplate>
                            </ListView.ItemTemplate>
                    </ListView>
                </DataTemplate>
            </rotator:SfRotator.ItemTemplate>
        </rotator:SfRotator>
 

We have created a sample for this. Please find the sample from the following location.
 
 
Sample Link: 
 
We request you to try our sample if your requirement is different from this, can you please share more detail information about your requirement. 
 
This will be helpful for us to provide you a good solution and improve us to serve you better. 
 
Regards, 
Muneesh Kumar G.   
 



LK Liam Keogh July 8, 2019 03:28 AM

This was exactly what I was looking for, thank you.



MK Muneesh Kumar G Syncfusion Team July 8, 2019 04:01 AM

Hi Liam,   
 
Thanks for the update. 
  
We are glad to know that the given solution works. Please let us know if you need any further assistance. 
 
Thanks, 
Muneesh Kumar G. 


Loader.
Live Chat Icon For mobile
Up arrow icon