CollectionViewのネスト
CollectionViewをネストすると,以下のような表示になる.
<CollectionView ItemsSource="{Binding AnimeInfos}"> <CollectionView.ItemsLayout> <LinearItemsLayout ItemSpacing="10" Orientation="Vertical" /> </CollectionView.ItemsLayout> <CollectionView.ItemTemplate> <DataTemplate> <Grid> <Frame BackgroundColor="LightPink"> <StackLayout> <Label Text="{Binding Title}" /> <Label Text="{Binding OfficialUrl}" /> <CollectionView BackgroundColor="LightBlue" ItemsSource="{Binding Schedules}" VerticalOptions="Center"> <CollectionView.ItemsLayout> <LinearItemsLayout Orientation="Vertical" /> </CollectionView.ItemsLayout> <CollectionView.ItemTemplate> <DataTemplate> <StackLayout VerticalOptions="Center"> <Label Text="{Binding Station}" /> <Label Text="{Binding DateTimeFrom}" /> </StackLayout> </DataTemplate> </CollectionView.ItemTemplate> </CollectionView> </StackLayout> </Frame> </Grid> </DataTemplate> </CollectionView.ItemTemplate> </CollectionView>
CollectionView使わないで,StackLayoutでBindableLayout使えばよかった.
<StackLayout> <Label FontSize="Large" Text="{Binding Title}" /> <Label HorizontalOptions="End" Text="{Binding Schedules[0].DateTimeFrom}" /> <StackLayout BindableLayout.ItemsSource="{Binding Schedules}"> <BindableLayout.ItemTemplate> <DataTemplate> <StackLayout> <Label Text="{Binding Station}" /> <Label Text="{Binding DateTimeFrom}" /> </StackLayout> </DataTemplate> </BindableLayout.ItemTemplate> </StackLayout>