dotnet-presentations/dotnet-maui-workshop

CollectionView cannot scroll when data overflows

Closed this issue · 3 comments

Hello,I'm new to .NET MAUI, I watched your video on YouTube and I saw you said that you don't need to put the CollectionView inside the scroll control to scroll, but when I try to do this on Android emulator and Windows, it Doesn't work unless the HeightRequest attribute is added, and then I found this related question through the search engine, saying that this is a normal design?(maui-issues-8888) So I'm wondering why your demo in the video doesn't have this problem. Thank you.

If you clone this repo, open the Finished folder project and run it does that work for you? It does for me and is scrolling fine.

I tested it here on my windows machine and android phone.

I also opened up the Part 2 folder, which is the where the video you linked to is. I added more monkeys into the hardcoded list and launched it and is scrolling fine for me here...

Thank you very much for getting back to me!
I apologize to you for not describing it clearly at first, what I meant was that scrolling doesn't work when the content is out of the visible range when the CollectionView is inside a VerticalStackLayout, like this:

 <VerticalStackLayout>
     <CollectionView>
         <! --... -->
     </CollectionView>
 </VerticalStackLayout>

This is also basically the same as described at the beginning of your YouTube video, but what you demonstrated in the video works, and what I tested doesn't.
I tested the Finished folder project, which uses a Grid instead of a VerticalStackLayout, and this won't be a problem because I also replaced it with a Grid the first time I encountered the problem above. like this:

 <Grid>
     <CollectionView>
         <! --... -->
     </CollectionView>
 </Grid>

Translated with DeepL.com (free version)

Yes you would want it in a grid or by itself.

If you put it in a VerticalStackLayout then it will not know the height that you need.