How do I add headers and footers to a ListView in .NET MAUI?

Platform: .NET MAUI| Category: Controls

To add headers and footers to a ListView use  the `Header` and `Footer` properties.

XAML

<ListView ItemsSource="{Binding MyItems}">
    <!-- Header -->
    <ListView.Header>
        <Label Text="ListView Header" FontSize="20" TextColor="Blue" />
    </ListView.Header>
    <!-- Footer -->
    <ListView.Footer>
        <Label Text="ListView Footer" FontSize="20" TextColor="Green" />
    </ListView.Footer>
    <ListView.ItemTemplate>
        <DataTemplate>
            <!-- Customize the appearance of each ListView item here -->
            <ViewCell>
                <StackLayout Padding="10">
                    <Label Text="{Binding}" FontSize="18" TextColor="Black" />
                    <Image Source="icon.png" HeightRequest="30" WidthRequest="30" />
                </StackLayout>
            </ViewCell>
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.