Search code examples
xamarinxamarin.iosxamarin.forms

Listview in xamarin form not using full space of form


I am working on Xamarin forms cross platform app. I have a form where i need to show data in listview.

Data is displaying but its not using entire space resulting in keeping unwanted space at bottom.

enter image description here

my xaml is as follows

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="BMTHomesApp.Views.ImportantAppointments">
    <ContentPage.Content>
        <StackLayout VerticalOptions="StartAndExpand">
            <ListView HasUnevenRows="True" RowHeight="100" HeightRequest="-1" x:Name="ListViewAppointments" VerticalOptions="StartAndExpand">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <ViewCell>
                            <Grid Padding="20,0,0,0" ColumnSpacing="20">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="40"></RowDefinition>
                                    <RowDefinition Height="40"></RowDefinition>
                                </Grid.RowDefinitions>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="40"></ColumnDefinition>
                                    <ColumnDefinition Width="*"></ColumnDefinition>
                                </Grid.ColumnDefinitions>

                                <!--<BoxView Color="#f7f7f7" Grid.Column="0" Grid.RowSpan="2"/>
                                <BoxView Color="#ffffff" Grid.Column="1" Grid.RowSpan="2"/>-->
                                <Image Grid.RowSpan="2" Grid.Column="0" x:Name="ImageAppointmentIcon" Source="AppointmentsIcon.png" Aspect="AspectFit"></Image>
                                <Label TextColor="#00344e" FontAttributes="Bold" Text="{Binding Subject}" Grid.Row="0" Grid.Column="1" VerticalTextAlignment="End"></Label>
                                <Label TextColor="#0073ae" Text="{Binding StartDate}" Grid.Row="1" Grid.Column="1" VerticalTextAlignment="Start"></Label>
                            </Grid>
                        </ViewCell>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
            <ActivityIndicator x:Name="ActLoder"  HorizontalOptions="CenterAndExpand" Color="#ffffff" VerticalOptions="CenterAndExpand"  />
        </StackLayout>
    </ContentPage.Content>
</ContentPage>

Solution

  • Could be the ActivityIndicator after the ListView. They are enclosed inside a StackLayout so will both take up space vertically.

    If you want the ActivityIndicator to appear over the top of the ListView, replace the StackLayout with a Grid.

    Not sure what the HeightRequest=-1 is there for.