Sergey
Sergey

Reputation: 18

How can I use ListView inside a CarouselView?

I'm trying to show data from my ObservableCollection named "Stats". It works good when I use this code:

<ListView
    Style="{StaticResource ListViewStyle}"
    ItemsSource="{Binding Stats}"
    HasUnevenRows="true">
    <ListView.ItemTemplate>
        <DataTemplate>
            <ViewCell>
            </ViewCell>
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>

But when I try to place this into the CarouselView like that:

<CarouselView>
     <CarouselView.ItemTemplate >
         <DataTemplate >
             <ListView
                Style="{StaticResource ListViewStyle}"
                ItemsSource="{Binding Stats}"
                HasUnevenRows="true">
                    <ListView.ItemTemplate>
                        <DataTemplate>
                            <ViewCell>
                            </ViewCell>
                        </DataTemplate>
                    </ListView.ItemTemplate>
             </ListView>
         </DataTemplate>
    </CarouselView.ItemTemplate>
</CarouselView>

It shows nothing. How can I use ListView inside?

Upvotes: 0

Views: 776

Answers (1)

Jason
Jason

Reputation: 89082

your Carousel needs an ItemsSource that will be a List<List<T>> (or something like that). Then your ListView's ItemsSource will be the inner List that is the current context of the Carousel. You should be able to bind the ListView's ItemsSource="{Binding .}"

Upvotes: 1

Related Questions