Langsung ke konten
Skillpedia
Aplikasi mobile5.8k Β· #14584

maui-collectionview

Fungsinya

Skill ini memandu pembuatan daftar dan grid data yang bisa digulir di aplikasi .NET MAUI dengan kontrol CollectionView. Skill ini untuk pengembang yang menampilkan kumpulan item di aplikasi seluler atau desktop.

Kapan dipakai

  • βœ“Saat Anda membutuhkan daftar atau grid data yang bisa digulir di aplikasi .NET MAUI.
  • βœ“Saat Anda ingin pemilihan, pengelompokan, tarik untuk menyegarkan, atau aksi geser pada daftar.
  • βœ“Saat Anda ingin memuat lebih banyak item saat pengguna menggulir.

Link skill

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

Salin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.

Cara pakai

Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.

Pesan siap tempel

Gunakan skill ini untuk membantu saya: https://github.com/dotnet/skills/blob/main/plugins/dotnet-maui/skills/maui-collectionview/SKILL.md Baca file SKILL.md di link tersebut dan ikuti instruksinya untuk tugas saya.
Mau AI Anda menemukan skill seperti ini sendiri?Pasang MCP Skillpedia gratis: cukup satu baris, dan AI mencari di antara 15.000+ skill sebelum tiap tugas.Pasang dalam 1 menit β†’

Contoh permintaan ke AI

β€œBuat layar MAUI yang menampilkan produk saya dalam grid dua kolom, dengan tarik untuk menyegarkan dan pesan kosong.”

5 skill baru setiap minggu. 1 menit baca.

Cara kerjanya

Agent memakai CollectionView dengan tata letak dan template item yang tepat, hanya menambahkan fitur yang dibutuhkan permintaan, dan menjaga kode yang ada tetap berfungsi.

Konten teknis (SKILL.md asli)

Teks asli dari pembuat, dalam bahasa Inggris, langsung dari 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

Pertanyaan umum

Apakah skill ini menambahkan fitur yang tidak saya minta?

Tidak. Skill ini dimaksudkan untuk menjawab pertanyaan yang diajukan, bukan menambahkan semua opsi.

Apakah item bisa dikelompokkan?

Ya. Pengelompokan termasuk fitur yang dicakup.

Bagaimana dengan tata letak statis?

Untuk jumlah item yang tetap, tata letak biasa seperti Grid lebih cocok.

Detail

Deskripsi asli dari pembuat

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

Popularitas

Bintang GitHub
5.8k
Peringkat
#14584
Lisensi
MIT
Diperbarui
2/11/2026

Apakah skill ini berguna?

0

Masuk untuk memberi suara.

Komentar

  • …

Skill lain dari repositori ini

Skill serupa