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.mdSalin 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
Untuk Claude Code, Codex, atau Cursor: jalankan di folder proyek, lalu skill langsung terpasang.
Unduh SKILL.md lalu taruh di folder skill agen Anda.
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
GridorStackLayoutdirectly - Map pin lists β use the
Microsoft.Maui.Controls.MapsNuGet package - Table-based data entry forms β use standard form controls
- Simple text-only lists with no interaction β consider
BindableLayouton aStackLayout
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, andListView-in-maintenance code have different rules. Do not rewriteListViewcode the user did not ask about β but if they ask which control to use, or are migrating from Xamarin.Forms, recommendCollectionView(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, ormaui-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:
- Never use
ViewCellas aDataTemplateroot inCollectionView. - Use
ObservableCollection<T>when the list mutates after first render. - Mutate the bound collection on the UI thread.
- Set
x:DataTypeon everyDataTemplate(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 toItemsSource - A
DataTemplatedefining 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
Komentar
- β¦
Skill lain dari repositori ini
create-custom-agent
5.8kMembantu agent Anda membuat file agen kustom VS Code dengan alatnya sendiri, instruksi, dan serah terima ke agent lain.
create-skill
5.8kMembantu agent Anda membuat skill agent baru dengan nama yang valid, deskripsi pemicu yang jelas, dan file SKILL.md yang mengikuti standar.
csharp-scripts
5.8kMembantu agent Anda menjalankan program C# kecil sebagai satu file dengan alat baris perintah .NET, tanpa membuat proyek lengkap.
dotnet-pinvoke
5.8kMembantu agent Anda memanggil pustaka native C atau C++ dari .NET dengan benar, mencakup tanda tangan, penanganan string, memori, dan safe handle.
Skill serupa
android-clean-architecture
280kMembuat agent Anda mengatur proyek Android dengan efisien. Struktur kodenya dibuat agar lebih mudah dirawat dan pengembangan fitur baru.
compose-multiplatform-patterns
280kMembantu agent Anda menggunakan pola Compose Multiplatform dan Jetpack Compose di proyek KMP, mencakup state, navigasi, theming, dan performa.
dart-flutter-patterns
280kMembuat agent Anda menulis kode untuk aplikasi Dart dan Flutter. Menggunakan pola modern agar aplikasi kokoh dan mudah dikelola.