0
votes

I'm facing this problem on Xamarin Forms: white empty space on listview

I want to fill that empty white space with the background image(i already tried verticaloptions and horizontaloptions = fillandexpand, but nothing happened)

XAML code:

  <StackLayout>
<ListView x:Name="MenuItemsListView"
          SeparatorVisibility="None"
          HasUnevenRows="true"
          ItemsSource="{Binding MenuItems}">
  <ListView.Header>
    <Grid BackgroundColor="GhostWhite">
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="10"/>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="10"/>
      </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="30"/>
                    <RowDefinition Height="80"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="10"/>
                </Grid.RowDefinitions>

                <Image Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="3" Grid.RowSpan="3" x:Name="circlebg" Source="" VerticalOptions="CenterAndExpand" HorizontalOptions="CenterAndExpand"></Image>
        
                <Frame Grid.Column="1" Grid.Row="1" x:Name="circleFrame" HasShadow="False" Padding="0" Margin="0" VerticalOptions="Center" HorizontalOptions="Center" BackgroundColor="Black" BorderColor="White" CornerRadius="10" IsClippedToBounds="True">
                        <Image x:Name="circleImg" Source=""></Image>
                    </Frame>
                
                <Label
          x:Name="txtName"
          Grid.Column="1"
          Grid.Row="2"
          TextColor="White"
          Text=""
          HorizontalTextAlignment="Center"
          FontFamily="{StaticResource Montserrat-Medium}"
          Style="{DynamicResource SubtitleStyle}"/>
            </Grid>
  </ListView.Header>
  <ListView.ItemTemplate>
    <DataTemplate>
                <ViewCell>

                    <StackLayout Orientation = "Horizontal" Margin = "10" HorizontalOptions="FillAndExpand">
                            <Image Source = "{Binding Image}" HorizontalOptions="Start" >
                                <Image.HeightRequest>
                                    <OnPlatform x:TypeArguments="x:Double">
                                    <On Platform="Android,Windows">30</On>
                                    </OnPlatform>
                                </Image.HeightRequest>
                            </Image>
                        <Label Text = "{Binding Title}" 
                                   VerticalOptions="FillAndExpand" 
                 FontFamily="{StaticResource Montserrat-Medium}"
                VerticalTextAlignment="Center"
                FontSize="18"/>

                    </StackLayout>
      </ViewCell>
    </DataTemplate>
  </ListView.ItemTemplate>
</ListView>
</StackLayout>

Someone there know how can i fix that? Thanks in advance

Update: Test 1 - Result: result test 1

<Image Aspect="Fill" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="3" Grid.RowSpan="3" x:Name="circlebg" Source="" VerticalOptions="CenterAndExpand" HorizontalOptions="CenterAndExpand"></Image>

Test 2 - Result: result test 2

1
are you talking about the Header or the ViewCell?Jason
i think it's the viewcell. When i click the hamburguer icon and then the menu appears. All the menu is ok, but where i want to place photo and a background photo, i have a white empty space. Look: i.stack.imgur.com/VeFrJ.jpgJonathan
I'd start by removing the MarginJason
The margin it's part of my menu list( ImageIcon - PageName). The problem is on the <image> above the <frame> and above <label txtName>Jonathan
That is clearly the header. I just asked you if it was the header and you said no.Jason

1 Answers

0
votes

Set the Aspect="Fill" to image and it will fill the space.

<Image Aspect="Fill" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="3" Grid.RowSpan="3" x:Name="circlebg" Source="Images"  VerticalOptions="CenterAndExpand" HorizontalOptions="CenterAndExpand"></Image>

Update:

        <Grid.RowDefinitions>
            <RowDefinition Height="30"/>
            <RowDefinition Height="80"/>
            <RowDefinition Height="100"/>
        </Grid.RowDefinitions>