Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
davidortinau avatar

Maui Collectionview

  • 42 installs
  • 163 repo stars
  • Updated July 6, 2026
  • davidortinau/maui-skills

Implements CollectionView in .NET MAUI apps for data display, list and grid layouts, selection, grouping, scrolling, empty views, and templates.

About

Guides implementing CollectionView in .NET MAUI apps including list and grid layouts, selection, grouping, scrolling, empty views and templates. A developer uses it when building scrollable data-driven lists or grids in a MAUI UI.

  • List and grid layouts with selection and grouping
  • Empty views and item templates

Maui Collectionview by the numbers

  • 42 all-time installs (skills.sh)
  • Ranked #623 of 1,039 Mobile Development skills by installs in the Skillselion catalog
  • Data as of Aug 3, 2026 (Skillselion catalog sync)
npx skills add https://github.com/davidortinau/maui-skills --skill maui-collectionview

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs42
repo stars163
Last updatedJuly 6, 2026
Repositorydavidortinau/maui-skills

What it does

Implements CollectionView in .NET MAUI apps for data display, list and grid layouts, selection, grouping, scrolling, empty views, and templates.

Files

SKILL.mdMarkdownGitHub ↗

CollectionView – .NET MAUI

Use CollectionView for displaying scrollable lists and grids of data. It replaces ListView and offers better performance, flexible layouts, and no ViewCell requirement.

Essential patterns

Basic setup

<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>
  • Bind ItemsSource to an ObservableCollection<T> so the UI updates on add/remove.
  • Each item template root must be a Layout or Viewnever use `ViewCell`.
  • Always set x:DataType on DataTemplate for compiled bindings.

SwipeView — binding from inside DataTemplate

Commands inside a DataTemplate can't directly reach your ViewModel. Use RelativeSource AncestorType:

<SwipeItem Text="Delete"
           BackgroundColor="Red"
           Command="{Binding Source={RelativeSource AncestorType={x:Type viewmodels:MainViewModel}}, Path=DeleteCommand}"
           CommandParameter="{Binding}" />

Pull-to-refresh

Wrap CollectionView in a RefreshView. Set IsRefreshing back to false when done:

<RefreshView IsRefreshing="{Binding IsRefreshing}"
             Command="{Binding RefreshCommand}">
    <CollectionView ItemsSource="{Binding Items}" />
</RefreshView>

Incremental loading (infinite scroll)

<CollectionView ItemsSource="{Binding Items}"
                RemainingItemsThreshold="5"
                RemainingItemsThresholdReachedCommand="{Binding LoadMoreCommand}" />
⚠️ Do NOT use with StackLayout-based ItemsLayout — it has no virtualization and triggers infinite threshold-reached events. Always use LinearItemsLayout or GridItemsLayout.

Performance tips

  • Use `MeasureFirstItem` for uniform item sizes — significantly faster than the default MeasureAllItems:
  <LinearItemsLayout Orientation="Vertical" ItemSizingStrategy="MeasureFirstItem" />
  • Always use `ObservableCollection<T>`, not List<T>. Swapping a List forces a full re-render.
  • Update collections on the UI threadMainThread.BeginInvokeOnMainThread(() => Items.Add(item)).

Common gotchas

IssueFix
UI doesn't update when items changeUse ObservableCollection<T>, not List<T>.
App crashes or blank itemsNever use `ViewCell` — use Grid, StackLayout, or any View as template root.
Items disappear or layout breaksAlways update ItemsSource and the collection on the UI thread (MainThread.BeginInvokeOnMainThread).
Incremental loading fires endlesslyDon't use StackLayout as layout; use LinearItemsLayout or GridItemsLayout.
EmptyView doesn't render correctlyWrap custom empty views in ContentView.
Poor scroll performanceUse MeasureFirstItem sizing strategy for uniform item sizes.
Selected state not visibleAdd VisualState Name="Selected" to the item template root element.
Binding errors in SwipeView commandsUse RelativeSource AncestorType to reach the ViewModel from inside the item template.

Related skills

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.