본문으로 건너뛰기
Skillpedia
모바일 앱5.8k · #14584

maui-collectionview

하는 일

이 스킬은 CollectionView 컨트롤로 .NET MAUI 앱에서 데이터의 스크롤 가능한 목록과 격자를 만드는 방법을 안내합니다. 모바일이나 데스크톱 앱에서 항목 모음을 보여 주는 개발자를 위한 스킬입니다.

사용하는 경우

  • ✓.NET MAUI 앱에 스크롤 가능한 데이터 목록이나 격자가 필요할 때.
  • ✓목록에 선택, 그룹화, 당겨서 새로 고침, 스와이프 동작을 넣고 싶을 때.
  • ✓사용자가 스크롤할 때 항목을 더 불러오고 싶을 때.

스킬 링크

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

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

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.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“제 상품을 두 열 격자로 보여 주고, 당겨서 새로 고침과 빈 목록 메시지가 있는 MAUI 화면을 만들어 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

에이전트가 알맞은 레이아웃과 항목 템플릿으로 CollectionView를 쓰고, 요청에 필요한 기능만 추가하며, 기존 코드가 계속 동작하도록 유지합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 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

자주 묻는 질문

요청하지 않은 기능도 추가하나요?

아니요. 이 스킬은 모든 옵션을 더하는 것이 아니라 요청받은 질문에 답하도록 만들어졌습니다.

항목을 그룹화할 수 있나요?

네. 그룹화는 다루는 기능 중 하나입니다.

고정된 레이아웃은 어떻게 하나요?

항목 수가 고정되어 있다면 Grid 같은 일반 레이아웃이 더 알맞습니다.

상세 정보

작성자의 원본 설명

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

인기도

GitHub 스타
5.8k
순위
#14584
라이선스
MIT
업데이트
2026. 11. 2.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬