George
George

Reputation: 2997

Grid rowspacing does not seem to work in PancakeView

I have the following XAML file:

<?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:yummy="clr-namespace:Xamarin.Forms.PancakeView;assembly=Xamarin.Forms.PancakeView"
             x:Class="BottomSlider.TestView">

    <yummy:PancakeView BackgroundColor="White"
                           Border="{yummy:BorderMarkup Color=Red, Thickness='1'} "
                           VerticalOptions="EndAndExpand"
                           x:Name="MyDraggableView"
                           CornerRadius="60,60,0,0"
                           HorizontalOptions="FillAndExpand"
                           HeightRequest="600" >

        <Grid>
            <Grid RowSpacing="0">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
            </Grid>

            <BoxView BackgroundColor="Red" Grid.Row="0"/>
            <BoxView BackgroundColor="YellowGreen" Grid.Row="1"/>
            <BoxView BackgroundColor="Aqua" Grid.Row="2"/>
            <BoxView BackgroundColor="Bisque" Grid.Row="3"/>
            <BoxView BackgroundColor="BlanchedAlmond" Grid.Row="4"/>
            <BoxView BackgroundColor="Blue" Grid.Row="5"/>
            <BoxView BackgroundColor="DimGray" Grid.Row="6"/>
            <BoxView BackgroundColor= "HotPink" Grid.Row="7"/>
            <BoxView BackgroundColor="Gold" Grid.Row="8"/>
        </Grid>
    </yummy:PancakeView>
</ContentPage>

It seems by setting RowSpacing="0" this does not seem to be working. The image that follows is what the xaml looks like after running it on the emulator.

Emulator screenshot

Upvotes: 0

Views: 173

Answers (1)

Cfun
Cfun

Reputation: 9671

You are defining two nested Grid, but setting RowSpacing="0" only in the inner one which is empty and does not contains your Boxview. To answer your question keep only one Grid:

<Grid RowSpacing="0">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
    </Grid.RowDefinitions>

    <BoxView BackgroundColor="Red" Grid.Row="0"/>
    <BoxView BackgroundColor="YellowGreen" Grid.Row="1"/>
    <BoxView BackgroundColor="Aqua" Grid.Row="2"/>
    <BoxView BackgroundColor="Bisque" Grid.Row="3"/>
    <BoxView BackgroundColor="BlanchedAlmond" Grid.Row="4"/>
    <BoxView BackgroundColor="Blue" Grid.Row="5"/>
    <BoxView BackgroundColor="DimGray" Grid.Row="6"/>
    <BoxView BackgroundColor= "HotPink" Grid.Row="7"/>
    <BoxView BackgroundColor="Gold" Grid.Row="8"/>
</Grid>

Or if for some reasons you want to keep both (at least in the code you shared, for me it doesn't make sens to have both), then you need to set it in the outter Grid 'the one that contains your BoxView:

<Grid RowSpacing="0">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
    </Grid>
....

Upvotes: 1

Related Questions