如何摆脱Xamarin Forms中网格行之间的空白行

时间:2019-05-09 16:54:10

标签: xamarin xamarin.forms

请注意此图像中第0行和第1行之间的空白(深蓝色)行...

enter image description here

我不确定该行来自哪里,但是如何摆脱它,以便两行之间没有间距?

这是XAML ...

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:control="clr-namespace:WP.MobileMidstream.Device.Pages"
             x:Class="WP.MobileMidstream.Device.Pages.LoginPage"             
             Visual="Material">
    <ContentPage.Resources>
        <Style x:Key="HeaderStyle" TargetType="Grid">
            <Setter Property="BackgroundColor" Value="#00458C" />
        </Style>
    </ContentPage.Resources>
    <ContentPage.Content>
        <Grid Style="{StaticResource HeaderStyle}" 
              Padding="0"
              Margin="0">
            <Grid.RowDefinitions>
                <RowDefinition Height="23" />
                <RowDefinition Height="56" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <BoxView Color="Red" 
                     Grid.Row="0"
                     Grid.Column="0"                      
                     Grid.ColumnSpan="2" 
                     Margin="0" />
            <Label Grid.Row="1"
                   Grid.Column="0"
                   Grid.ColumnSpan="2"
                   VerticalTextAlignment="Center"
                   HorizontalTextAlignment="Center"
                   BackgroundColor="RosyBrown"
                   Margin="0"
                   FontSize="20"
                   TextColor="White">Daily Run Sheet</Label>
            <Image Source="hamburger_icon" 
                   Margin="10, 0, 0, 0"
                   Grid.Row="1"
                   Grid.Column="0" />
        </Grid>
    </ContentPage.Content>
</ContentPage>

1 个答案:

答案 0 :(得分:1)

我认为第二行的ColSpan和Column分配错误:

 <Label Grid.Row="1"
               Grid.Column="1"
               VerticalTextAlignment="Center"
               HorizontalTextAlignment="Center"
               BackgroundColor="RosyBrown"
               Margin="0"
               FontSize="20"
               TextColor="White">Daily Run Sheet</Label>
        <Image Source="hamburger_icon" 
               Margin="10, 0, 0, 0"
               Grid.Row="1"
               Grid.Column="0" />

更新: 尝试在网格上将RowSpacing设置为0。