HorizontalStackLayout 不应该等于 Orientation="Horizontal" 和 FillAndExpand .NET MAUI

问题描述 投票:0回答:1

我正在 .NET MAUI 中制作一个简单的应用程序,但我注意到当我使用 HorizontalStackLayout 时,我没有得到与 Orientation="Horizontal" 和 HorizontalOptions="FillAndExpand" 的 StackLayout 相同的结果。

这是我正在使用的xaml:

<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>

下图比较结果:

设计结果 StackLayout Orientation="Horizontal" HorizontalOptions="FillAndExpand"

设计结果HorizontalStackLayout

.net maui
1个回答
0
投票

FillAndExpand 和所有其他 AndExpand 类型在 MAUI 中已弃用,如果您现在想执行此操作,则需要使用 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>
© www.soinside.com 2019 - 2024. All rights reserved.