LittleCat27
LittleCat27

Reputation: 7

Shouldn't HorizontalStackLayout be equal to Orientation="Horizontal" with FillAndExpand .NET MAUI

Im making a simple application in .NET MAUI, but i noticed when i use HorizontalStackLayout, i don't get the same results as a StackLayout with Orientation="Horizontal" and HorizontalOptions="FillAndExpand".

This is the xaml i'm using:

<StackLayout Orientation="Horizontal" HorizontalOptions="FillAndExpand">
    <Entry x:Name="InfoNombre" Placeholder="Nombre" Text="{Binding EditorPerfil.conta.InfoNombre}"  HorizontalOptions="FillAndExpand"/>
    <Entry x:Name="InfoApellido" Placeholder="Apellido" Text="{Binding EditorPerfil.conta.InfoApellido}"  HorizontalOptions="FillAndExpand"/>
</StackLayout>

Vs

<HorizontalStackLayout  HorizontalOptions="FillAndExpand"> <!--Note that using HorizontalOptions="Fill" gets me the same result-->
    <Entry x:Name="InfoNombre" Placeholder="Nombre" Text="{Binding EditorPerfil.conta.InfoNombre}"  HorizontalOptions="FillAndExpand"/>
    <Entry x:Name="InfoApellido" Placeholder="Apellido" Text="{Binding EditorPerfil.conta.InfoApellido}"  HorizontalOptions="FillAndExpand"/>
</HorizontalStackLayout>

Image Below comparing results:

Design Result StackLayout Orientation="Horizontal" HorizontalOptions="FillAndExpand"

Design Result HorizontalStackLayout

Upvotes: 0

Views: 116

Answers (1)

FreakyAli
FreakyAli

Reputation: 16547

FillAndExpand and all other AndExpand types are deprecated in MAUI, if you want to do this now you need to use Grid

<Grid ColumnDefinitions="*,*">
    <Entry x:Name="InfoNombre" Grid.Column="0" Placeholder="Nombre" Text="{Binding EditorPerfil.conta.InfoNombre}" />
    <Entry x:Name="InfoApellido" Grid.Column="1" Placeholder="Apellido" Text="{Binding EditorPerfil.conta.InfoApellido}" />
</Grid>

Upvotes: 1

Related Questions