Search code examples
xamlmaui.net-mauimaui-windows

Frame size not applying? - XAML MAUI


I am trying to make a frame a specific size but the frame seems to only match the size with components inside of the frame.

I tried finding solutions but couldn't find anything, perhaps I am searching for the wrong things.

The XAML:

<ScrollView>
        <VerticalStackLayout
            Spacing="25"
            Padding="30,0"
            VerticalOptions="Center">

            <Frame BackgroundColor="#303030"
                   Padding="8" CornerRadius="5"
                   HeightRequest="500" WidthRequest="500">

                <StackLayout Spacing="10">
                    <Label Text="Login" FontSize="Medium" FontAttributes="Bold" />
                    <BoxView Color="{DynamicResource Primary}" HeightRequest="2" HorizontalOptions="Fill" />

                    <Entry Placeholder="Username" />
                    <Entry Placeholder="Password" IsPassword="True" />

                    <Button Text="Login" BackgroundColor="{DynamicResource Primary}" TextColor="{DynamicResource White}" />
                </StackLayout>
            </Frame>
        </VerticalStackLayout>
    </ScrollView>

What it looks like: enter image description here

What I want it to look like:enter image description here


Solution

  • View toolmakersteve's response if you have this "issue" too!

    Code:

    <ScrollView>
        <VerticalStackLayout
                Spacing="25"
                Padding="30,0"
                VerticalOptions="Center"
                WidthRequest="400"
                HeightRequest="400">
            <Border BackgroundColor="#303030"
                       Padding="8">
                <StackLayout Spacing="10">
                    <Label Text="Login" FontSize="Medium" FontAttributes="Bold" />
                    <BoxView Color="{DynamicResource Primary}" HeightRequest="2" HorizontalOptions="Fill" />
                    <Entry Placeholder="Username" />
                    <Entry Placeholder="Password" IsPassword="True" />
                    <Button Text="Login" BackgroundColor="{DynamicResource Primary}" TextColor="{DynamicResource White}" Clicked="LoginClick" />
                </StackLayout>
            </Border>
        </VerticalStackLayout>
    </ScrollView>
    

    Result: enter image description here