Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

CollectionView doesn't scroll when inside a Stacklayout inside a Grid inside another CollectionView

philipzhengphilipzheng Member ✭✭
edited July 2 in Xamarin.Forms

I'm not very surprised that this doesn't work. But perhaps I am missing something. As you can see, the last record is cut off by the edge of the Post and pulling it around only scrolls the parent CollectionView, not the CollectionView inside the Grid.

Page:

<ContentPage.Content>
<RefreshView>
<StackLayout>
<CollectionView ItemsSource="{Binding Posts}"> <!-- This will scroll-->
<CollectionView.ItemTemplate>
<DataTemplate><social:PostView /></DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</StackLayout>
</RefreshView>
</ContentPage.Content>

Post:

<ContentView.Content>
        <Frame>
            <StackLayout>
                <Grid>
                    <StackLayout>
                        <CollectionView ItemsSource="{Binding Suppliers}"> <!-- This does not scroll-->
                            <CollectionView.ItemTemplate>
                                <DataTemplate>
                                    <datatemplates:SupplierSummaryTemplate /> <!-- Each of these is one record-->
                                </DataTemplate>
                            </CollectionView.ItemTemplate>
                        </CollectionView>
                    </StackLayout>
                </Grid>
            </StackLayout>
        </Frame>
    </ContentView.Content>

Best Answer

  • igorkr_10igorkr_10 Member ✭✭✭✭
    Accepted Answer

    You can change a CollectionView in PostView to CarouselView (or to horizontal CollectionView)

Answers

  • ColeXColeX Member, Xamarin Team Xamurai

    It is not a good ui design to wrap collectionview inside another collectionview ,the gesture would conflict when scrolling.

    Could you try to replace the outer collectionview with ListView ?

  • igorkr_10igorkr_10 Member ✭✭✭✭
    Accepted Answer

    You can change a CollectionView in PostView to CarouselView (or to horizontal CollectionView)

  • philipzhengphilipzheng Member ✭✭

    Thanks for your answers. ListView didn't work with my datatemplate. It gave an error for some reason. But horizontal CollectionView worked well.

                        <CollectionView ItemsSource="{Binding Suppliers}">
                            <CollectionView.ItemsLayout>
                                <GridItemsLayout Orientation="Horizontal" Span="3" />
                            </CollectionView.ItemsLayout>
                            <CollectionView.ItemTemplate>
                                <DataTemplate>
                                    <datatemplates:SupplierSummaryTemplate />
                                </DataTemplate>
                            </CollectionView.ItemTemplate>
                        </CollectionView>
    
Sign In or Register to comment.