aspnet-core
Build, debug, modernize, or review ASP.NET Core applications with correct hosting, middleware, security, configuration, logging, and deployment patterns on…
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
$ npx -y skills add managedcode/dotnet-skills --skill maui-collectionview --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/maui-collectionviewContext preview
The summary Claude sees to decide when to auto-load this skill.
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
name: maui-collectionview description: > 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.Maps), table-based data entry forms, non-MAUI list controls, CarouselView or BindableLayout questions, platform-specific handler or renderer customization, diagnosing CollectionView bugs in the MAUI framework itself, or general MVVM/binding questions that merely happen to mention a list (use maui-data-binding). license: MIT
`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.
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:**
grouping, swipe actions, empty views, snap points, or performance tips that were not asked about.
match the examples here. Point out a concrete defect; if there is none, say so and answer the question that was asked.
a template that already behaves correctly is churn, not a fix.
`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](#migrating-from-listview)).
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.
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, or the XAML will not compile.
The inline `<ContentPage.BindingContext>` above keeps the example self-contained. In an app that uses dependency injection, register the ViewModel instead and assign it through constructor injection (`BindingContext = vm;`) — see the **maui-dependency-injection** skill.
**Key rules:**
Stop explaining .NET to your AI. Start building. We've all been there: asking Claude to use Entity Framework, only to get EF6 patterns in a .NET 8 project. Explaining to Copilot that Blazor Server and Blazor WebAssembly aren't the same thing.
Repo: managedcode/dotnet-skills
Build, debug, modernize, or review ASP.NET Core applications with correct hosting, middleware, security, configuration, logging, and deployment patterns on…
Build, upgrade, and operate Aspire 13.5.x C# or TypeScript application hosts with the current CLI, AppHost, ServiceDefaults, integrations, dashboard, testing,…
Build, review, or migrate Azure Functions in .NET with correct execution model, isolated worker setup, bindings, DI, and Durable Functions patterns. USE FOR:…
Build and review Blazor applications across server, WebAssembly, web app, and hybrid scenarios with correct component design, state flow, rendering, and…
Maintain or migrate EF6-based applications with realistic guidance on what to keep, what to modernize, and when EF Core is or is not the right next step. USE…
Design, tune, or review EF Core data access with proper modeling, migrations, query translation, performance, and lifetime management for modern .NET…