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

fix width constraint when measuring stacklayout children #6239

Merged
merged 1 commit into from
Apr 19, 2022

Conversation

tmijieux
Copy link
Contributor

Description of Change

Substract stacklayout padding from width constraint when measuring stacklayout children

Fixes #4142

There may be some other issue somewhere because it seems to only happens with grid, but this fix here might be part of the solution.

My understanding of layout system is very limited , i've seen old information about xamarin.forms but i can't tell from what i read if the system is still working the same or not.
https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/layouts/custom
https://www.youtube.com/watch?v=sxjOqNZFhKU

I think some controls is using the size computed by Measure to draw itself, and ignore the width passed in VerticalStackLayoutManager.ArrangeChildren (which seems correct there).

The following is very simple code (just replace MainPage from template) to reproduce the issue and see the effect of the fix:

<ContentPage
  xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
  xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
  x:Class="MyApp.MainPage"
  NavigationPage.HasNavigationBar="True"
  NavigationPage.HasBackButton="True"
    Title="Test">
    <ScrollView>
        <VerticalStackLayout x:Name="MyStack" Spacing="20" Padding="20">
            <Grid ColumnDefinitions="*" BackgroundColor="Green" Padding="10">
                <Frame BackgroundColor="Yellow" CornerRadius="0"  BorderColor="Red"/>
            </Grid>
            <Grid ColumnDefinitions="*" BackgroundColor="Green" Padding="10">
                <BoxView BackgroundColor="Yellow" CornerRadius="0" HeightRequest="50" />
            </Grid>
            <Frame BackgroundColor="Yellow" CornerRadius="0" BorderColor="Red"/>

        </VerticalStackLayout>
    </ScrollView>
</ContentPage>

Issues Fixed

Fixes #4142

@rmarinho rmarinho requested a review from hartez April 19, 2022 16:58
@rmarinho
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@rmarinho
Copy link
Member

Can you add a unit test ?

@hartez hartez merged commit d7f9b08 into dotnet:main Apr 19, 2022
hartez added a commit that referenced this pull request Apr 20, 2022
hartez added a commit that referenced this pull request Apr 20, 2022
@tmijieux tmijieux deleted the fix-stack-layout-measure branch April 22, 2022 07:40
@github-actions github-actions bot locked and limited conversation to collaborators Dec 23, 2023
@samhouts samhouts added the fixed-in-6.0.300-rc.2 Look for this fix in 6.0.300-rc.2! label Aug 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
fixed-in-6.0.300-rc.2 Look for this fix in 6.0.300-rc.2!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Grid width stretches off the page
4 participants