mbrmj
mbrmj

Reputation: 129

How to set FlexLayout height automatically according to its children height

I'm trying to create a FlexLayout without specifying its height as I am supposing it will get it from its children height. When I'm doing so, the FlexLayout is not displayed at all. Here is a simple code:

<FlexLayout Direction="Column">
    <Button Text="Test Button" />
    <!-- Here I'm trying to create FlexLayout without specifying its height -->
    <FlexLayout JustifyContent="Start" AlignItems="Start" AlignContent="Start" BackgroundColor="Blue" Direction="RowReverse" Wrap="Wrap">
        <Label Text="Test Label" HeightRequest="50" WidthRequest="50"  BackgroundColor="Yellow" />
    </FlexLayout>
</FlexLayout>

I tried everything but nothing works unless I specify HeightRequest or FlexLayout.Basis for the (inner) FlexLayout. Any Suggestions will be appreciated.

Upvotes: 3

Views: 1817

Answers (1)

mbrmj
mbrmj

Reputation: 129

If I changed the first FlexLayout to StackLayout as follows, it will work. This is so weird as I assume it should work without changing it to StackLayout :

<StackLayout Orientation="Vertical" Spacing="0">
    <Button Text="Test Button" />
    <FlexLayout JustifyContent="Start" AlignItems="Start" AlignContent="Start" BackgroundColor="Blue" Direction="RowReverse" Wrap="Wrap">
        <Label Text="Test Label" HeightRequest="50" WidthRequest="50"  BackgroundColor="Yellow" />
    </FlexLayout>
</StackLayout>

Upvotes: 4

Related Questions