Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ListView inside ContentView inside StackLayout: scrolling does not work #24455

Closed
janusw opened this issue Aug 27, 2024 · 5 comments
Closed

ListView inside ContentView inside StackLayout: scrolling does not work #24455

janusw opened this issue Aug 27, 2024 · 5 comments
Labels
area-controls-listview ListView and TableView platform/android 🤖 platform/iOS 🍎 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working

Comments

@janusw
Copy link
Contributor

janusw commented Aug 27, 2024

Description

The scrolling of ListViews (and similar controls) seems to be broken under certain circumstances. I observed this in several cases (mostly with ListViews and TableViews) and could trace it down to the condition that the ListView is inside a ContentView, which itself is inside a StackLayout. See reproducer below, which is derived from the ListViewDemos in the maui-samples repo (and also contains a workaround for #24308).

I see the problem both on Android (v14), where almost no scrolling is possible, and on iOS (v16.7), where it seems to work a bit better, but still one cannot scroll all the way down to the bottom of the list.

Probably the root cause of the issue is a problem with the sizing of the ListView (which does not seem to be constrained probably)?

Steps to Reproduce

  1. Build and run the ListViewDemos project on this branch of my maui-samples fork: https://github.com/janusw/maui-samples/tree/ListView_bug_repro/8.0/UserInterface/Views/ListViewDemos
  2. Select "ListView with DataTemplate".
  3. Observe that scrolling is broken. The last item in the list is the "Gelada", which cannot be made visible at all (Android) or only shortly when dragging the view, but then snaps back (iOS).

Link to public reproduction project repository

https://github.com/janusw/maui-samples/tree/ListView_bug_repro/8.0/UserInterface/Views/ListViewDemos

Version with bug

8.0.80 SR8

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

iOS, Android

Affected platform versions

seen on Android 14, iOS 16

Did you find any workaround?

  • Remove the StackLayout completely.
  • Use a different layout (e.g. a Grid).
  • Remove the ContentView and place the ListView directly in the StackLayout (as it is the case in the original ListViewDemos).

Relevant log output

No response

@janusw janusw added the t/bug Something isn't working label Aug 27, 2024
Copy link
Contributor

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

@drasticactions
Copy link
Contributor

#12452 (comment)

I believe you're seeing this. In short, you shouldn't put a ListView inside a StackLayout as the controls inside of the StackLayout are not constrained unless you specifically set up the heights/widths.

So, unless you specifically set constraints for the ListView, it's going to render the entire List (breaking Virtualization) and generally won't be scrollable. So the right thing to do here is use a Grid, since then it should have proper constraints for the heights.

@PureWeen is my reading on this correct?

@janusw
Copy link
Contributor Author

janusw commented Aug 29, 2024

#12452 (comment)

I believe you're seeing this. In short, you shouldn't put a ListView inside a StackLayout as the controls inside of the StackLayout are not constrained unless you specifically set up the heights/widths.

Thanks for the comment, @drasticactions. In fact I have seen this issue (and similar ones).

But the thing that I really don't understand is: Why does it make a difference for the behavior, whether I put the ListView into a StackLayout directly, or whether I put it into a ContentView that is inside a StackLayout? That does not seem consistent (to me).

@Zhanglirong-Winnie Zhanglirong-Winnie added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Aug 29, 2024
@Zhanglirong-Winnie
Copy link

This issue has been verified using Visual Studio 17.12.0 Preview 1.0(8.0.80 & 8.0.72). Can repro on iOS and Android platforms.

@PureWeen
Copy link
Member

Duplicate of #24078

dotnet/maui-samples#507

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-listview ListView and TableView platform/android 🤖 platform/iOS 🍎 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants