Xamarin堆栈布局重叠部分

Xamarin堆栈布局重叠部分,xamarin,xamarin.forms,stacklayout,Xamarin,Xamarin.forms,Stacklayout,我是Xamarin的新手,我正在尝试创建一个表单 当不包括其他堆栈布局时,第一个堆栈布局显示为OK 在添加第二个堆栈布局之后,我得到了这个 这是我正在使用的代码: <ContentPage.Content> <StackLayout> <grial:TabControl> <grial:TabItem Text="Fuel Setup">

我是Xamarin的新手,我正在尝试创建一个表单

当不包括其他堆栈布局时,第一个堆栈布局显示为OK

在添加第二个堆栈布局之后,我得到了这个

这是我正在使用的代码:

<ContentPage.Content>
        <StackLayout>
            <grial:TabControl>
                <grial:TabItem Text="Fuel Setup">
                    <Grid>
                        <StackLayout Margin="10,10,10,10" HeightRequest="60" Orientation="Horizontal" HorizontalOptions="FillAndExpand">
                            <Stepper Maximum="360" Increment="1" HorizontalOptions="Center" ValueChanged="Stepper_ValueChanged" VerticalOptions="StartAndExpand" />
                            <Label x:Name="lblGallons" Text="Gallons" />
                            <Entry x:Name="txtGallons" WidthRequest="130" />
                        </StackLayout>
                        <StackLayout HorizontalOptions="FillAndExpand" HeightRequest="300">
                            <Editor x:Name="txtNotes" VerticalOptions="Center" />
                        </StackLayout>-->
                    </Grid>
                </grial:TabItem>
            </grial:TabControl>
        </StackLayout>
    </ContentPage.Content>

-->

我是否需要每个视图只有一个堆栈布局,或者是因为控件重叠而“有罪”

如果您只想垂直堆放物品,只需使用
StackLayout
而不是
grid

<StackLayout>
  <StackLayout Margin="10,10,10,10" HeightRequest="60" Orientation="Horizontal" HorizontalOptions="FillAndExpand">
    <Stepper Maximum="360" Increment="1" HorizontalOptions="Center" ValueChanged="Stepper_ValueChanged" VerticalOptions="StartAndExpand" />
    <Label x:Name="lblGallons" Text="Gallons" />
    <Entry x:Name="txtGallons" WidthRequest="130" />
  </StackLayout>
  <StackLayout HorizontalOptions="FillAndExpand" HeightRequest="300">
    <Editor x:Name="txtNotes" VerticalOptions="Center" />
  </StackLayout>-->
</StackLayout>

-->

如果您只想让您的物品垂直堆叠,只需使用
堆叠布局
而不是
网格

<StackLayout>
  <StackLayout Margin="10,10,10,10" HeightRequest="60" Orientation="Horizontal" HorizontalOptions="FillAndExpand">
    <Stepper Maximum="360" Increment="1" HorizontalOptions="Center" ValueChanged="Stepper_ValueChanged" VerticalOptions="StartAndExpand" />
    <Label x:Name="lblGallons" Text="Gallons" />
    <Entry x:Name="txtGallons" WidthRequest="130" />
  </StackLayout>
  <StackLayout HorizontalOptions="FillAndExpand" HeightRequest="300">
    <Editor x:Name="txtNotes" VerticalOptions="Center" />
  </StackLayout>-->
</StackLayout>

-->

如果要在网格中进行此布局,请尝试下面的代码

<Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="55" ></RowDefinition>
            <RowDefinition Height="55" ></RowDefinition>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="180"></ColumnDefinition>
            <ColumnDefinition Width="50"></ColumnDefinition>
            <ColumnDefinition Width="*"></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <Stepper Grid.Row="0" Grid.Column="0"  Maximum="360" Increment="1" HorizontalOptions="Center" VerticalOptions="StartAndExpand"/>
        <Label Grid.Row="0" Grid.Column="1" x:Name="lblGallons" Text="Gallons" />
        <Entry Grid.Row="0" Grid.Column="2" x:Name="txtGallons" WidthRequest="50" />
        <Editor Grid.Row="1" Grid.Column="0" x:Name="txtNotes" VerticalOptions="Center"></Editor>
    </Grid>


注意:使用网格时,需要首先使用
RowDefinition
ColumnDefinition
定义行和列。然后使用
Grid.Row
Grid.Column
指定行和列。

如果要在网格中进行此布局,请尝试下面的代码

<Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="55" ></RowDefinition>
            <RowDefinition Height="55" ></RowDefinition>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="180"></ColumnDefinition>
            <ColumnDefinition Width="50"></ColumnDefinition>
            <ColumnDefinition Width="*"></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <Stepper Grid.Row="0" Grid.Column="0"  Maximum="360" Increment="1" HorizontalOptions="Center" VerticalOptions="StartAndExpand"/>
        <Label Grid.Row="0" Grid.Column="1" x:Name="lblGallons" Text="Gallons" />
        <Entry Grid.Row="0" Grid.Column="2" x:Name="txtGallons" WidthRequest="50" />
        <Editor Grid.Row="1" Grid.Column="0" x:Name="txtNotes" VerticalOptions="Center"></Editor>
    </Grid>


注意:使用网格时,需要首先使用
RowDefinition
ColumnDefinition
定义行和列。然后使用
Grid.Row
Grid.Column
来指定行和列。

您有一个没有定义行或列的网格,因此该网格中的每个项目都将彼此重叠thx@Jason您能告诉我应该更正什么吗您有一个没有定义行或列的网格,所以网格中的每一个项目都是一个接一个的Thx@Jason你能告诉我我应该纠正什么吗