Question CollectionView iOS - not all items visible

DarthSerpical

New member
Joined
Nov 29, 2021
Messages
1
Programming Experience
10+
I am using a nested CollectionView. My first CollectionView is vertical, and the nest one is horizontal. On Android, everything is fine. On iOS however, on first load I can see all my horizontal items (vertical doesn't have any issues), but on second load, I only ever see the first item in the horizontal list. I removed any HeightRequests, adn now iOS loads fine, but the horizontal CollectionView fills the page, rather than just the height of the items. Below is my XAML:
XML:
                <StackLayout>
                    <CollectionView
                        ItemSizingStrategy="MeasureFirstItem"
                        ItemsSource="{Binding MyVerticalItems}"
                        SelectionMode="Single">
                        <CollectionView.ItemsLayout>
                            <LinearItemsLayout ItemSpacing="5" Orientation="Vertical" />
                        </CollectionView.ItemsLayout>
                        <CollectionView.ItemTemplate>
                            <DataTemplate>
                                <StackLayout Padding="10">
                                    <StackLayout Orientation="Horizontal">
                                        <StackLayout Padding="5">
                                            <Frame
                                                Padding="0"
                                                CornerRadius="50"
                                                HeightRequest="100"
                                                HorizontalOptions="Center"
                                                IsClippedToBounds="True"
                                                WidthRequest="100">
                                                <ffimageloading:CachedImage
                                                    Aspect="AspectFill"
                                                    DownsampleToViewSize="True"
                                                    HeightRequest="100"
                                                    HorizontalOptions="Center"
                                                    LoadingPlaceholder="{Binding MyImage}"
                                                    Source="{Binding InstructorImage}"
                                                    WidthRequest="100">
                                                    <ffimageloading:CachedImage.Transformations>
                                                        <ffTrans:CircleTransformation />
                                                    </ffimageloading:CachedImage.Transformations>
                                                </ffimageloading:CachedImage>
                                            </Frame>
                                        </StackLayout>
                                        <Label
                                            HorizontalOptions="StartAndExpand"
                                            Style="{StaticResource HeadingText}"
                                            Text="{Binding MyName}"
                                            VerticalOptions="CenterAndExpand" />
                                    </StackLayout>
                                    <CollectionView
                                        ItemSizingStrategy="MeasureFirstItem"
                                        ItemsSource="{Binding MyHorizontalItems}"
                                        SelectionMode="Single">
                                        <CollectionView.ItemsLayout>
                                            <LinearItemsLayout ItemSpacing="5" Orientation="Horizontal" />
                                        </CollectionView.ItemsLayout>
                                        <CollectionView.ItemTemplate>
                                            <DataTemplate>
                                                <StackLayout Padding="-5,10,5,5">
                                                    <Frame
                                                        Margin="5,0"
                                                        CornerRadius="10">
                                                        <Grid>
                                                            <Grid.RowDefinitions>
                                                                <RowDefinition Height="*" />
                                                                <RowDefinition Height="*" />
                                                                <RowDefinition Height="*" />
                                                            </Grid.RowDefinitions>
                                                            <StackLayout Grid.Row="0" Orientation="Horizontal">
                                                                <Label
                                                                    HorizontalOptions="Start"
                                                                    Text="{Binding MyLabel1}"
                                                                    VerticalOptions="Start" />
                                                                <Label
                                                                    HorizontalOptions="Start"
                                                                    Text="{Binding MyLabel2"
                                                                    VerticalOptions="Start" />
                                                                <Label
                                                                    HorizontalOptions="Start"
                                                                    Text="{Binding MyLabel3}"
                                                                    VerticalOptions="Start" />
                                                            </StackLayout>
                                                            <Label
                                                                Grid.Row="1"
                                                                HorizontalOptions="Start"
                                                                Text="{Binding MyLabel4}"
                                                                VerticalOptions="Start" />
                                                            <StackLayout Grid.Row="2">
                                                                <StackLayout Orientation="Horizontal">
                                                                    <Label
                                                                        Text="{Binding MyLabel5}"
                                                                        VerticalOptions="CenterAndExpand" />
                                                                    <Label
                                                                        Text="{Binding MyLabel6}"
                                                                        VerticalOptions="CenterAndExpand" />
                                                                </StackLayout>
                                                            </StackLayout>
                                                        </Grid>
                                                    </Frame>
                                                </StackLayout>
                                            </DataTemplate>
                                        </CollectionView.ItemTemplate>
                                    </CollectionView>
                                    <BoxView
                                        HeightRequest="2"
                                        HorizontalOptions="FillAndExpand"
                                        Color="{StaticResource SecondaryColour}" />
                                </StackLayout>
                            </DataTemplate>
                        </CollectionView.ItemTemplate>
                    </CollectionView>
                </StackLayout>
 
Last edited by a moderator:
Back
Top Bottom