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

[Proposal] ScrollView inside a VerticalStackLayout #26891

Conversation

kubaflo
Copy link
Contributor

@kubaflo kubaflo commented Dec 31, 2024

Description of Change

ScrollView inside a VerticalStackLayout will not scroll unless its height is explicitly set because it defaults to having an infinite height. This behavior often confuses developers and results in a poor experience when working with .NET MAUI. For example

If developers explicitly set a height for the ScrollView, that value would keep on taking precedence over the calculated height.

Issues Fixed

Fixes https://stackoverflow.com/questions/75465567/workaround-for-scrollview-not-scrolling-inside-a-stacklayout-in-maui

Workarounds

For developers who happen to encounter this PR and are looking for a workaround:

  • Instead of VerticalStackLayout use StackLayout and add FillAndExpand to VerticalOptions of your scroll view
  • Use grid and * as row definition
  • Explicitly calculate the height of your ScrollView and assign it to its HeightRequest

@kubaflo kubaflo requested a review from a team as a code owner December 31, 2024 23:54
@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Dec 31, 2024
Copy link
Contributor

Hey there @kubaflo! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

Copy link
Member

@PureWeen PureWeen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if you have multiple scroll views?

If the scroll view is off the screen because of the content above it how do we define "available space"

The operating behavior of a vsl is that it's infinite so any constraints you try to assume start to rabbit hole a bit.

Current behaviour is consistent with wpf/winui

I do think this is a problem that would be nice to have a wider out of success though.

Like maybe a way to use a grid measurement system against the stack layout.

@kubaflo
Copy link
Contributor Author

kubaflo commented Jan 4, 2025

@PureWeen yea you're right. I'm closing this PR for now then. At least, now, some developers will know why sv might not work as expected in the stack layout

@kubaflo kubaflo closed this Jan 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants