Skip to content
Skillpedia
Mobile apps5.8k Β· #14584

maui-collectionview

What it does

This skill guides building scrollable lists and grids of data in .NET MAUI apps with the CollectionView control. It is for developers showing collections of items in mobile or desktop apps.

When to use it

  • βœ“When you need a scrollable list or grid of data in a .NET MAUI app.
  • βœ“When you want selection, grouping, pull to refresh or swipe actions on a list.
  • βœ“When you want to load more items as the user scrolls.

Skill link

https://github.com/dotnet/skills/blob/main/plugins/dotnet-maui/skills/maui-collectionview/SKILL.md

Copy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.

How to use

The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.

Ready-to-paste message

Use this skill to help me: https://github.com/dotnet/skills/blob/main/plugins/dotnet-maui/skills/maui-collectionview/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute β†’

Example of what to ask your AI

β€œBuild a MAUI screen that shows my products in a two-column grid with pull to refresh and an empty message.”

5 new skills a week. 1 minute to read.

How it works

The agent uses CollectionView with the right layout and item template, adds only the features the request needs, and keeps the existing code working.

Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

CollectionView β€” .NET MAUI

CollectionView is the primary control for displaying scrollable lists and grids of data in .NET MAUI. It replaces ListView with better performance, flexible layouts, and no ViewCell requirement.

When to Use

  • Displaying a scrollable list or grid of data items
  • Binding a collection of objects to a templated item layout
  • Adding selection (single or multiple), grouping, or pull-to-refresh
  • Implementing infinite scroll / incremental loading
  • Showing swipe actions on list items
  • Displaying an empty state when no data is available

When Not to Use

  • Static layouts with a fixed number of items β€” use Grid or StackLayout directly
  • Map pin lists β€” use the Microsoft.Maui.Controls.Maps NuGet package
  • Table-based data entry forms β€” use standard form controls
  • Simple text-only lists with no interaction β€” consider BindableLayout on a StackLayout

Scope Control β€” Answer Only What Was Asked

This skill is a reference you consult, not a checklist you apply. Most requests need one or two sections from it. Pulling in the rest makes the answer worse.

Stop conditions β€” do NOT act when:

  • The user asked a narrow question. Answer that question only. Do not append grouping, swipe actions, empty views, snap points, or performance tips that were not asked about.
  • The user's existing code already works. Do not rewrite working markup to match the examples here. Point out a concrete defect; if there is none, say so and answer the question that was asked.
  • The change is stylistic. Renaming, reordering attributes, or restructuring a template that already behaves correctly is churn, not a fix.
  • The control isn't CollectionView. CarouselView, BindableLayout, and ListView-in-maintenance code have different rules. Do not rewrite ListView code the user did not ask about β€” but if they ask which control to use, or are migrating from Xamarin.Forms, recommend CollectionView (see Migrating from ListView).
  • The problem is really a binding, DI, or navigation problem that happens to involve a list β€” defer to maui-data-binding, maui-dependency-injection, or maui-shell-navigation.

The API sections below are a reference, not a checklist β€” offer them only when relevant. Four rules are non-negotiable, because violating them produces code that does not work or silently loses compile-time checking:

  1. Never use ViewCell as a DataTemplate root in CollectionView.
  2. Use ObservableCollection<T> when the list mutates after first render.
  3. Mutate the bound collection on the UI thread.
  4. Set x:DataType on every DataTemplate (and on the page root) for compiled bindings.

Everything else β€” sizing strategy, snap points, header/footer, empty views β€” is optional and should be offered only when it addresses the user's actual problem.

Inputs

  • A data source (typically ObservableCollection<T>) bound to ItemsSource
  • A DataTemplate defining how each item renders
  • Optional: layout configuration, selection mode, grouping model, empty view

Basic Setup

A complete, copy-pasteable page. Two things are load-bearing: the xmlns:models declaration that every x:DataType="models:Item" in this skill assumes, and the root x:DataType β€” without it the outer ItemsSource binding is not compiled:

<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:models="clr-namespace:MyApp.Models"
             xmlns:vm="clr-namespace:MyApp.ViewModels"
             x:DataType="vm:ItemsViewModel"
             x:Class="MyApp.ItemsPage">
    <ContentPage.BindingContext>
        <vm:ItemsViewModel />
    </ContentPage.BindingContext>
    <CollectionView ItemsSource="{Binding Items}">
        <CollectionView.ItemTemplate>
            <DataTemplate x:DataType="models:Item">
                <HorizontalStackLayout Padding="8" Spacing="8">
                    <Image Source="{Binding Icon}" WidthRequest="40" HeightRequest="40" />
                    <Label Text="{Binding Name}" VerticalOptions="Center" />
                </HorizontalStackLayout>
            </DataTemplate>
        </CollectionView.ItemTemplate>
    </CollectionView>
</ContentPage>

Later snippets show only the CollectionView element. When you hand a snippet to a user, include the matching xmlns: declaration for any prefix it uses

FAQ

Does it add extra features I did not ask for?

No. The skill is meant to answer the question asked, not to add every option.

Can it group items?

Yes. Grouping is one of the covered features.

What about static layouts?

For a fixed number of items, plain layouts such as Grid are a better fit.

Details

Original description by the author

Guidance for implementing CollectionView in .NET MAUI apps β€” data display, layouts (list & grid), selection, grouping, scrolling, empty views, templates, incremental loading, swipe actions, and pull-to-refresh. USE FOR: "CollectionView", "list view", "grid layout", "data template", "item template", "grouping", "pull to refresh", "incremental loading", "swipe actions", "empty view", "selection mode", "scroll to item", displaying scrollable data, replacing ListView. DO NOT USE FOR: simple static layouts without scrollable data (use Grid or StackLayout), map pin lists (use Microsoft.Maui.Controls

repo: dotnet/skills

Popularity

GitHub stars
5.8k
Ranking position
#14584
License
MIT
Updated
11/2/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills