Xamarin.forms Xamarin表单-将BoxView移动到单元格底部

Xamarin.forms Xamarin表单-将BoxView移动到单元格底部,xamarin.forms,Xamarin.forms,我试图用XAML创建一个简单的选项卡控件。一切都很好,但是应该扩展选项卡底线的底部BoxView在网格单元的顶部绘制。如何将其移动到网格单元的底部?我有一个红色箭头指向应该在底部的线(BoxView) 你可以看到我有VerticalOptions=End,但它没有任何作用。它总是在顶部绘制 我尝试了你的代码,但没有出现这样的问题。我做了一些修改,您可以检查效果是否符合您的需要: <Grid HorizontalOptions="FillAndExpand" Margin="10,0,10

我试图用XAML创建一个简单的选项卡控件。一切都很好,但是应该扩展选项卡底线的底部BoxView在网格单元的顶部绘制。如何将其移动到网格单元的底部?我有一个红色箭头指向应该在底部的线(BoxView)

你可以看到我有VerticalOptions=End,但它没有任何作用。它总是在顶部绘制


我尝试了你的代码,但没有出现这样的问题。我做了一些修改,您可以检查效果是否符合您的需要:

<Grid HorizontalOptions="FillAndExpand" Margin="10,0,10,0" ColumnSpacing="0">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <BoxView Grid.Column="0"
                BackgroundColor="Gray" />
        <BoxView Grid.Column="0"
                Margin="1,1,0,1"
                BackgroundColor="White" />

        <Label Grid.Column="0"
            HorizontalTextAlignment="Center"
            Text="Run Tickets" />
        <BoxView Grid.Column="1"
                BackgroundColor="Gray" />
        <BoxView Grid.Column="1"
                Margin="1,1,0,1"
                BackgroundColor="White" />
        <Label Grid.Column="1"
            HorizontalTextAlignment="Center"
            Text="Readings" />
        <BoxView Grid.Column="2"
                BackgroundColor="Gray" />
        <BoxView Grid.Column="2"
                Margin="1,1,1,1"
                BackgroundColor="White" />
        <Label Grid.Column="2"
            HorizontalTextAlignment="Center"
            Text="Adjustments" />
</Grid>

我运行了您发布的代码,我发现这行代码没有问题。iOS和Android(设备)都显示了网格底部的线条

使用红色,以便于注意

正如可以看到的那样,问题在于这条线落后于其他线。要解决这个问题,只需将行声明移动到网格中的最后一个

<Grid HorizontalOptions="FillAndExpand" Margin="10,0,10,0">
    <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <BoxView Grid.Column="0"
                    BackgroundColor="Gray" />
        <BoxView Grid.Column="0"
                    Margin="1,1,0,0"
                    BackgroundColor="White" />
        <Label Grid.Column="0"
                HorizontalTextAlignment="Center"
                Text="Run Tickets" />
        <BoxView Grid.Column="1"
                    BackgroundColor="Gray" />
        <BoxView Grid.Column="1"
                    Margin="1,1,0,1"
                    BackgroundColor="White" />
        <Label Grid.Column="1"
                HorizontalTextAlignment="Center"
                Text="Readings" />
        <BoxView Grid.Column="2"
                    BackgroundColor="Gray" />
        <BoxView Grid.Column="2"
                    Margin="1,1,1,1"
                    BackgroundColor="White" />
        <Label Grid.Column="2"
                HorizontalTextAlignment="Center"
                Text="Adjustments" />

        <BoxView Grid.Row="0" 
                    Grid.Column="0" 
                    Grid.ColumnSpan="3" 
                    BackgroundColor="Red" 
                    HeightRequest="1" 
                    Margin="0,20,0,0"
                    VerticalOptions="End"
                    />
</Grid>
大概是这样的:

<Grid HorizontalOptions="FillAndExpand"          
      RowSpacing="0"
      Margin="10,0,10,0">
    <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <BoxView Grid.Column="0"
                    BackgroundColor="Gray" />
        <BoxView Grid.Column="0"
                    Margin="1,1,0,0"
                    BackgroundColor="White" />
        <Label Grid.Column="0"
                HorizontalTextAlignment="Center"
                Text="Run Tickets" />
        <BoxView Grid.Column="1"
                    BackgroundColor="Gray" />
        <BoxView Grid.Column="1"
                    Margin="1,1,0,1"
                    BackgroundColor="White" />
        <Label Grid.Column="1"
                HorizontalTextAlignment="Center"
                Text="Readings" />
        <BoxView Grid.Column="2"
                    BackgroundColor="Gray" />
        <BoxView Grid.Column="2"
                    Margin="1,1,1,1"
                    BackgroundColor="White" />
        <Label Grid.Column="2"
                HorizontalTextAlignment="Center"
                Text="Adjustments" />
        <BoxView Grid.Row="1"
                 Grid.ColumnSpan="3" 
                 BackgroundColor="Gray" 
                 HeightRequest="1" 
                 Margin="0,20,0,0"
                 VerticalOptions="End" />
</Grid>

希望这有帮助-

<Grid HorizontalOptions="FillAndExpand"          
      RowSpacing="0"
      Margin="10,0,10,0">
    <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <BoxView Grid.Column="0"
                    BackgroundColor="Gray" />
        <BoxView Grid.Column="0"
                    Margin="1,1,0,0"
                    BackgroundColor="White" />
        <Label Grid.Column="0"
                HorizontalTextAlignment="Center"
                Text="Run Tickets" />
        <BoxView Grid.Column="1"
                    BackgroundColor="Gray" />
        <BoxView Grid.Column="1"
                    Margin="1,1,0,1"
                    BackgroundColor="White" />
        <Label Grid.Column="1"
                HorizontalTextAlignment="Center"
                Text="Readings" />
        <BoxView Grid.Column="2"
                    BackgroundColor="Gray" />
        <BoxView Grid.Column="2"
                    Margin="1,1,1,1"
                    BackgroundColor="White" />
        <Label Grid.Column="2"
                HorizontalTextAlignment="Center"
                Text="Adjustments" />
        <BoxView Grid.Row="1"
                 Grid.ColumnSpan="3" 
                 BackgroundColor="Gray" 
                 HeightRequest="1" 
                 Margin="0,20,0,0"
                 VerticalOptions="End" />
</Grid>