[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7D1TP2QND24VNYKMVTQCNAE":3,"skill-same:01M7D1TP2QND24VNYKMVTQCNAE":51},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":25,"commitSha":26,"skillDirectory":27,"forksCount":14,"repositoryHtmlUrl":28,"repositoryHomepageUrl":6,"ownerHtmlUrl":29,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":30,"install":31,"resources":44},"01M7D1TP2QND24VNYKMVTQCNAE","maui-collectionview",null,"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\u002Fbinding questions that merely happen to mention a list (use maui-data-binding).","itsmejay18\u002FAI-Skills-for-My-Development-Stack","itsmejay18","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F167779943?v=4","01M7CZRFC6DDZA5V2CX8WDSZED","Jay Jemino Ababon ","01M7CZRFCVRNW1SFHSQXEJ3CQN",0,"MIT","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F10-Mobile-Development\u002Fmaui-collectionview\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: maui-collectionview\ndescription: >\n  Guidance for implementing CollectionView in .NET MAUI apps — data display,\n  layouts (list & grid), selection, grouping, scrolling, empty views, templates,\n  incremental loading, swipe actions, and pull-to-refresh.\n  USE FOR: \"CollectionView\", \"list view\", \"grid layout\", \"data template\",\n  \"item template\", \"grouping\", \"pull to refresh\", \"incremental loading\",\n  \"swipe actions\", \"empty view\", \"selection mode\", \"scroll to item\",\n  displaying scrollable data, replacing ListView.\n  DO NOT USE FOR: simple static layouts without scrollable data (use Grid or\n  StackLayout), map pin lists (use Microsoft.Maui.Controls.Maps), table-based\n  data entry forms, non-MAUI list controls, CarouselView or BindableLayout\n  questions, platform-specific handler or renderer customization, diagnosing\n  CollectionView bugs in the MAUI framework itself, or general MVVM\u002Fbinding\n  questions that merely happen to mention a list (use maui-data-binding).\nlicense: MIT\n---\n\n# CollectionView — .NET MAUI\n\n`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.\n\n## When to Use\n\n- Displaying a scrollable list or grid of data items\n- Binding a collection of objects to a templated item layout\n- Adding selection (single or multiple), grouping, or pull-to-refresh\n- Implementing infinite scroll \u002F incremental loading\n- Showing swipe actions on list items\n- Displaying an empty state when no data is available\n\n## When Not to Use\n\n- Static layouts with a fixed number of items — use `Grid` or `StackLayout` directly\n- Map pin lists — use the `Microsoft.Maui.Controls.Maps` NuGet package\n- Table-based data entry forms — use standard form controls\n- Simple text-only lists with no interaction — consider `BindableLayout` on a `StackLayout`\n\n## Scope Control — Answer Only What Was Asked\n\nThis skill is a **reference you consult**, not a checklist you apply. Most requests\nneed one or two sections from it. Pulling in the rest makes the answer worse.\n\n**Stop conditions — do NOT act when:**\n\n- **The user asked a narrow question.** Answer that question only. Do not append\n  grouping, swipe actions, empty views, snap points, or performance tips that\n  were not asked about.\n- **The user's existing code already works.** Do not rewrite working markup to\n  match the examples here. Point out a concrete defect; if there is none, say so\n  and answer the question that was asked.\n- **The change is stylistic.** Renaming, reordering attributes, or restructuring\n  a template that already behaves correctly is churn, not a fix.\n- **The control isn't `CollectionView`.** `CarouselView`, `BindableLayout`, and\n  `ListView`-in-maintenance code have different rules. Do not rewrite `ListView`\n  code the user did not ask about — but if they ask *which* control to use, or are\n  migrating from Xamarin.Forms, recommend `CollectionView` (see\n  [Migrating from ListView](#migrating-from-listview)).\n- **The problem is really a binding, DI, or navigation problem** that happens to\n  involve a list — defer to `maui-data-binding`, `maui-dependency-injection`, or\n  `maui-shell-navigation`.\n\n**The API sections below are a reference, not a checklist — offer them only when\nrelevant.** Four rules are non-negotiable, because violating them produces code that\ndoes not work or silently loses compile-time checking:\n\n1. Never use `ViewCell` as a `DataTemplate` root in `CollectionView`.\n2. Use `ObservableCollection\u003CT>` when the list mutates after first render.\n3. Mutate the bound collection on the UI thread.\n4. Set `x:DataType` on every `DataTemplate` (and on the page root) for compiled bindings.\n\nEverything else — sizing strategy, snap points, header\u002Ffooter, empty views — is\noptional and should be offered only when it addresses the user's actual problem.\n\n## Inputs\n\n- A data source (typically `ObservableCollection\u003CT>`) bound to `ItemsSource`\n- A `DataTemplate` defining how each item renders\n- Optional: layout configuration, selection mode, grouping model, empty view\n\n## Basic Setup\n\nA complete, copy-pasteable page. Two things are load-bearing: the `xmlns:models`\ndeclaration that every `x:DataType=\"models:Item\"` in this skill assumes, and the\n**root `x:DataType`** — without it the outer `ItemsSource` binding is not compiled:\n\n```xml\n\u003CContentPage xmlns=\"http:\u002F\u002Fschemas.microsoft.com\u002Fdotnet\u002F2021\u002Fmaui\"\n             xmlns:x=\"http:\u002F\u002Fschemas.microsoft.com\u002Fwinfx\u002F2009\u002Fxaml\"\n             xmlns:models=\"clr-namespace:MyApp.Models\"\n             xmlns:vm=\"clr-namespace:MyApp.ViewModels\"\n             x:DataType=\"vm:ItemsViewModel\"\n             x:Class=\"MyApp.ItemsPage\">\n    \u003CContentPage.BindingContext>\n        \u003Cvm:ItemsViewModel \u002F>\n    \u003C\u002FContentPage.BindingContext>\n    \u003CCollectionView ItemsSource=\"{Binding Items}\">\n        \u003CCollectionView.ItemTemplate>\n            \u003CDataTemplate x:DataType=\"models:Item\">\n                \u003CHorizontalStackLayout Padding=\"8\" Spacing=\"8\">\n                    \u003CImage Source=\"{Binding Icon}\" WidthRequest=\"40\" HeightRequest=\"40\" \u002F>\n                    \u003CLabel Text=\"{Binding Name}\" VerticalOptions=\"Center\" \u002F>\n                \u003C\u002FHorizontalStackLayout>\n            \u003C\u002FDataTemplate>\n        \u003C\u002FCollectionView.ItemTemplate>\n    \u003C\u002FCollectionView>\n\u003C\u002FContentPage>\n```\n\nLater snippets show only the `CollectionView` element. When you hand a snippet to a\nuser, include the matching `xmlns:` declaration for any prefix it uses, or the XAML\nwill not compile.\n\nThe inline `\u003CContentPage.BindingContext>` above keeps the example self-contained. In\nan app that uses dependency injection, register the ViewModel instead and assign it\nthrough constructor injection (`BindingContext = vm;`) — see the\n**maui-dependency-injection** skill.\n\n**Key rules:**\n\n- Bind `ItemsSource` to an `ObservableCollection\u003CT>` so the UI updates on add\u002Fremove.\n- Each item template root must be a `Layout` or `View` — **never use `ViewCell`**.\n- Always set `x:DataType` on `DataTemplate` for compiled bindings.\n\n## Layouts\n\nSet `ItemsLayout` to control arrangement. Default is `VerticalList`.\n\n| Layout | XAML value |\n|---|---|\n| Vertical list | `VerticalList` (default) |\n| Horizontal list | `HorizontalList` |\n| Vertical grid | `GridItemsLayout` with `Orientation=\"Vertical\"` |\n| Horizontal grid | `GridItemsLayout` with `Orientation=\"Horizontal\"` |\n\n### Grid Layout\n\n```xml\n\u003CCollectionView ItemsSource=\"{Binding Items}\">\n    \u003CCollectionView.ItemsLayout>\n        \u003CGridItemsLayout Orientation=\"Vertical\"\n                         Span=\"2\"\n                         VerticalItemSpacing=\"8\"\n                         HorizontalItemSpacing=\"8\" \u002F>\n    \u003C\u002FCollectionView.ItemsLayout>\n    \u003CCollectionView.ItemTemplate>\n        \u003CDataTemplate x:DataType=\"models:Item\">\n            \u003CBorder Padding=\"8\" StrokeThickness=\"0\">\n                \u003CVerticalStackLayout>\n                    \u003CImage Source=\"{Binding Image}\" HeightRequest=\"120\" Aspect=\"AspectFill\" \u002F>\n                    \u003CLabel Text=\"{Binding Name}\" FontAttributes=\"Bold\" \u002F>\n                \u003C\u002FVerticalStackLayout>\n            \u003C\u002FBorder>\n        \u003C\u002FDataTemplate>\n    \u003C\u002FCollectionView.ItemTemplate>\n\u003C\u002FCollectionView>\n```\n\n### Horizontal List\n\n```xml\n\u003CCollectionView ItemsSource=\"{Binding Items}\"\n                ItemsLayout=\"HorizontalList\" \u002F>\n```\n\n## Selection\n\n### Selection Mode\n\n| Mode | Property to bind | Binding mode |\n|---|---|---|\n| `None` | — | — |\n| `Single` | `SelectedItem` | `TwoWay` |\n| `Multiple` | `SelectedItems` | `OneWay` |\n\n```xml\n\u003CCollectionView ItemsSource=\"{Binding Items}\"\n                SelectionMode=\"Single\"\n                SelectedItem=\"{Binding CurrentItem, Mode=TwoWay}\"\n                SelectionChangedCommand=\"{Binding ItemSelectedCommand}\" \u002F>\n```\n\nFor `Multiple` selection, bind `SelectedItems` (type `IList\u003Cobject>`):\n\n```xml\n\u003CCollectionView SelectionMode=\"Multiple\"\n                SelectedItems=\"{Binding ChosenItems, Mode=OneWay}\" \u002F>\n```\n\n### Selected Visual State\n\nHighlight selected items using `VisualStateManager`:\n\n```xml\n\u003CCollectionView.ItemTemplate>\n    \u003CDataTemplate x:DataType=\"models:Item\">\n        \u003CGrid Padding=\"8\">\n            \u003CVisualStateManager.VisualStateGroups>\n                \u003CVisualStateGroup Name=\"CommonStates\">\n                    \u003CVisualState Name=\"Normal\">\n                        \u003CVisualState.Setters>\n                            \u003CSetter Property=\"BackgroundColor\" Value=\"Transparent\" \u002F>\n                        \u003C\u002FVisualState.Setters>\n                    \u003C\u002FVisualState>\n                    \u003CVisualState Name=\"Selected\">\n                        \u003CVisualState.Setters>\n                            \u003CSetter Property=\"BackgroundColor\"\n                                    Value=\"{AppThemeBinding Light={StaticResource Primary}, Dark={StaticResource PrimaryDark}}\" \u002F>\n                        \u003C\u002FVisualState.Setters>\n                    \u003C\u002FVisualState>\n                \u003C\u002FVisualStateGroup>\n            \u003C\u002FVisualStateManager.VisualStateGroups>\n            \u003CLabel Text=\"{Binding Name}\" \u002F>\n        \u003C\u002FGrid>\n    \u003C\u002FDataTemplate>\n\u003C\u002FCollectionView.ItemTemplate>\n```\n\n## Grouping\n\n1. Create a group class inheriting from `List\u003CT>`:\n\n```csharp\npublic class AnimalGroup : List\u003CAnimal>\n{\n    public string Name { get; }\n    public AnimalGroup(string name, List\u003CAnimal> animals) : base(animals)\n    {\n        Name = name;\n    }\n}\n```\n\n2. Bind to `ObservableCollection\u003CAnimalGroup>` and set `IsGrouped=\"True\"`:\n\n```xml\n\u003CCollectionView ItemsSource=\"{Binding AnimalGroups}\"\n                IsGrouped=\"True\">\n    \u003CCollectionView.GroupHeaderTemplate>\n        \u003CDataTemplate x:DataType=\"models:AnimalGroup\">\n            \u003CLabel Text=\"{Binding Name}\"\n                   FontAttributes=\"Bold\"\n                   BackgroundColor=\"{StaticResource Gray100}\"\n                   Padding=\"8\" \u002F>\n        \u003C\u002FDataTemplate>\n    \u003C\u002FCollectionView.GroupHeaderTemplate>\n    \u003CCollectionView.ItemTemplate>\n        \u003CDataTemplate x:DataType=\"models:Animal\">\n            \u003CLabel Text=\"{Binding Name}\" Padding=\"16,4\" \u002F>\n        \u003C\u002FDataTemplate>\n    \u003C\u002FCollectionView.ItemTemplate>\n\u003C\u002FCollectionView>\n```\n\n## Pull-to-Refresh\n\nWrap `CollectionView` in a `RefreshView`. Set `IsRefreshing` back to `false` when done:\n\n```xml\n\u003CRefreshView IsRefreshing=\"{Binding IsRefreshing}\"\n             Command=\"{Binding RefreshCommand}\">\n    \u003CCollectionView ItemsSource=\"{Binding Items}\" \u002F>\n\u003C\u002FRefreshView>\n```\n\n## Incremental Loading (Infinite Scroll)\n\n```xml\n\u003CCollectionView ItemsSource=\"{Binding Items}\"\n                RemainingItemsThreshold=\"5\"\n                RemainingItemsThresholdReachedCommand=\"{Binding LoadMoreCommand}\" \u002F>\n```\n\n> ⚠️ **Do NOT use with non-virtualizing layouts.** `LinearItemsLayout` and `GridItemsLayout` support virtualization. Using `BindableLayout` on a `StackLayout` as an alternative to `CollectionView` has no virtualization, which triggers infinite threshold-reached events.\n\n## SwipeView — Binding from Inside DataTemplate\n\nCommands inside a `DataTemplate` can't directly reach your ViewModel. Use `RelativeSource AncestorType`:\n\n```xml\n\u003CCollectionView.ItemTemplate>\n    \u003CDataTemplate x:DataType=\"models:Item\">\n        \u003CSwipeView>\n            \u003CSwipeView.RightItems>\n                \u003CSwipeItems>\n                    \u003CSwipeItem Text=\"Delete\"\n                               BackgroundColor=\"Red\"\n                               Command=\"{Binding BindingContext.DeleteCommand, Source={RelativeSource AncestorType={x:Type ContentPage}}}\"\n                               CommandParameter=\"{Binding}\" \u002F>\n                \u003C\u002FSwipeItems>\n            \u003C\u002FSwipeView.RightItems>\n            \u003CGrid Padding=\"8\">\n                \u003CLabel Text=\"{Binding Name}\" \u002F>\n            \u003C\u002FGrid>\n        \u003C\u002FSwipeView>\n    \u003C\u002FDataTemplate>\n\u003C\u002FCollectionView.ItemTemplate>\n```\n\n## EmptyView\n\nShown when `ItemsSource` is empty or null.\n\n```xml\n\u003CCollectionView ItemsSource=\"{Binding SearchResults}\"\n                EmptyView=\"No items found.\" \u002F>\n```\n\nFor a custom empty view, wrap in `ContentView`:\n\n```xml\n\u003CCollectionView ItemsSource=\"{Binding SearchResults}\">\n    \u003CCollectionView.EmptyView>\n        \u003CContentView>\n            \u003CVerticalStackLayout HorizontalOptions=\"Center\" VerticalOptions=\"Center\">\n                \u003CImage Source=\"empty_state.png\" WidthRequest=\"120\" \u002F>\n                \u003CLabel Text=\"Nothing here yet\" HorizontalTextAlignment=\"Center\" \u002F>\n            \u003C\u002FVerticalStackLayout>\n        \u003C\u002FContentView>\n    \u003C\u002FCollectionView.EmptyView>\n\u003C\u002FCollectionView>\n```\n\n## Headers and Footers\n\n```xml\n\u003CCollectionView ItemsSource=\"{Binding Items}\">\n    \u003CCollectionView.Header>\n        \u003CLabel Text=\"Header\" FontAttributes=\"Bold\" Padding=\"8\" \u002F>\n    \u003C\u002FCollectionView.Header>\n    \u003CCollectionView.Footer>\n        \u003CLabel Text=\"Footer\" FontAttributes=\"Italic\" Padding=\"8\" \u002F>\n    \u003C\u002FCollectionView.Footer>\n\u003C\u002FCollectionView>\n```\n\nUse `HeaderTemplate` \u002F `FooterTemplate` when headers or footers are data-bound.\n\n## Scrolling\n\n### ScrollTo\n\nProgrammatically scroll by index or item:\n\n```csharp\n\u002F\u002F Scroll to index\ncollectionView.ScrollTo(index: 10, position: ScrollToPosition.Center, animate: true);\n\n\u002F\u002F Scroll to item\ncollectionView.ScrollTo(item: myItem, position: ScrollToPosition.MakeVisible, animate: true);\n```\n\n| ScrollToPosition | Behavior |\n|---|---|\n| `MakeVisible` | Scrolls just enough to make the item visible |\n| `Start` | Scrolls item to the start of the viewport |\n| `Center` | Scrolls item to the center of the viewport |\n| `End` | Scrolls item to the end of the viewport |\n\n### Snap Points\n\n```xml\n\u003CCollectionView.ItemsLayout>\n    \u003CLinearItemsLayout Orientation=\"Horizontal\"\n                       SnapPointsType=\"MandatorySingle\"\n                       SnapPointsAlignment=\"Center\" \u002F>\n\u003C\u002FCollectionView.ItemsLayout>\n```\n\n- `SnapPointsType`: `None`, `Mandatory`, `MandatorySingle`\n- `SnapPointsAlignment`: `Start`, `Center`, `End`\n\n## Migrating from ListView\n\n`ListView` still compiles, but **as of .NET 10** it is marked `[Obsolete]`\n(\"*ListView is deprecated. Please use CollectionView instead.*\"). It is **not**\nobsolete on .NET 9 and earlier, so check the project's target framework before\ndescribing it as deprecated. **If the user asks\nwhich control to use, or is migrating from Xamarin.Forms, recommend\n`CollectionView`** — it is faster, needs no `ViewCell`, and supports flexible\nlayouts. What to avoid is silently rewriting `ListView` code the user did not ask\nyou to touch.\n\n| `ListView` | `CollectionView` equivalent |\n|---|---|\n| `ViewCell` template root | Any `View`\u002F`Layout` root — **`ViewCell` is not supported** |\n| `ItemSelected` event | `SelectionChanged` event, or `SelectionChangedCommand` |\n| `ItemTapped` event | A `TapGestureRecognizer` in the item template — `SelectionChanged` only fires when the selection *changes*, so it will not re-fire on tapping the already-selected item |\n| `IsPullToRefreshEnabled` + `Refreshing` | Wrap the `CollectionView` in a `RefreshView` |\n| `IsGroupingEnabled` | `IsGrouped` |\n| `HasUnevenRows=\"True\"` | Default `ItemSizingStrategy=\"MeasureAllItems\"` |\n| `RowHeight` (fixed height) | Set the height in the item template. `MeasureFirstItem` only reuses the first item's measured size — it is not an explicit row height |\n| `SeparatorVisibility` \u002F `SeparatorColor` | **No equivalent** — draw a `BoxView`\u002F`Border` in the item template |\n\nThe missing separator API is the most common migration surprise: `CollectionView`\nhas no built-in separators, so add one to the template yourself.\n\n## Performance Tips\n\nApply these only when the user reports a performance problem or explicitly asks\nabout performance — they are not a default checklist.\n\n- **Use `MeasureFirstItem`** for uniform item sizes — significantly faster than the default\n  `MeasureAllItems`, which measures every item individually. Set it on the `CollectionView`\n  itself (it is declared on `StructuredItemsView`), **not** on `LinearItemsLayout` \u002F\n  `GridItemsLayout`:\n  ```xml\n  \u003CCollectionView ItemsSource=\"{Binding Items}\"\n                  ItemSizingStrategy=\"MeasureFirstItem\">\n      \u003CCollectionView.ItemTemplate>\n          \u003CDataTemplate x:DataType=\"models:Item\">\n              \u003CGrid Padding=\"8\" ColumnDefinitions=\"44,*\" ColumnSpacing=\"8\">\n                  \u003CImage WidthRequest=\"44\" HeightRequest=\"44\" \u002F>\n                  \u003CLabel Grid.Column=\"1\" Text=\"{Binding Name}\" VerticalOptions=\"Center\" \u002F>\n              \u003C\u002FGrid>\n          \u003C\u002FDataTemplate>\n      \u003C\u002FCollectionView.ItemTemplate>\n  \u003C\u002FCollectionView>\n  ```\n  **When `MeasureFirstItem` is the wrong choice** — keep the default `MeasureAllItems` if:\n  - Items vary in height (wrapping text, optional rows, images of differing aspect) — the\n    first item's size is applied to all, so the rest are clipped or stretched.\n  - A `DataTemplateSelector` returns different templates — the first item won't represent\n    the others.\n  - The first item is atypical (a header-like or \"featured\" row) — every item inherits its\n    size. Fixing this by reordering data is a smell; use `MeasureAllItems` instead.\n  - Item size depends on runtime data that isn't loaded yet when the first item is measured.\n- **Use `ObservableCollection\u003CT>` when the list mutates after first render.** It implements\n  `INotifyCollectionChanged`, so in-place `Add`\u002F`Remove`\u002F`Insert` update the UI incrementally.\n  A `List\u003CT>` is fine for a list that never changes after it is bound. Note that *replacing*\n  `ItemsSource` re-renders everything regardless of the collection type — so mutate the bound\n  collection in place rather than reassigning it.\n- **Update collections on the UI thread** — `MainThread.BeginInvokeOnMainThread(() => Items.Add(item))`.\n\n## Common Pitfalls\n\n| Issue | Fix |\n|---|---|\n| UI doesn't update when items change | Use `ObservableCollection\u003CT>`, not `List\u003CT>`. |\n| App crashes or blank items | **Never use `ViewCell`** — use `Grid`, `StackLayout`, or any `View` as template root. |\n| Items disappear or layout breaks | Always update `ItemsSource` and the collection on the **UI thread** (`MainThread.BeginInvokeOnMainThread`). |\n| Incremental loading fires endlessly | Don't use `StackLayout` as layout; use `LinearItemsLayout` or `GridItemsLayout`. |\n| EmptyView doesn't render correctly | Wrap custom empty views in `ContentView`. |\n| Poor scroll performance | Use `MeasureFirstItem` sizing strategy for uniform item sizes. |\n| `ItemSizingStrategy` doesn't compile | It is declared on `StructuredItemsView` — set it on `\u003CCollectionView>`, not on `\u003CLinearItemsLayout>` \u002F `\u003CGridItemsLayout>`. |\n| Items clipped or stretched | `MeasureFirstItem` assumes uniform item size. Use the default `MeasureAllItems` for variable-height items. |\n| Selected state not visible | Add `VisualState Name=\"Selected\"` to the item template root element. |\n| Binding errors in SwipeView commands | Use `RelativeSource AncestorType` to reach the ViewModel from inside the item template. |\n\n## Validation\n\nBefore returning CollectionView markup you wrote or edited, confirm:\n\n- [ ] The `DataTemplate` root is a `View`\u002F`Layout` — **not** `ViewCell`.\n- [ ] `DataTemplate` declares `x:DataType` for compiled bindings.\n- [ ] `ItemsSource` is bound to `ObservableCollection\u003CT>` if the list mutates.\n- [ ] `ItemSizingStrategy` (if used) is on `\u003CCollectionView>`, not on the layout.\n- [ ] `Multiple` selection binds `SelectedItems`; `Single` binds `SelectedItem` (`TwoWay`).\n- [ ] `RefreshView.IsRefreshing` is set back to `false` when the refresh completes.\n- [ ] The answer covers **only** what the user asked — no unrequested sections.\n\n## References\n\n- [CollectionView overview](https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fmaui\u002Fuser-interface\u002Fcontrols\u002Fcollectionview\u002F)\n- [CollectionView layout](https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fmaui\u002Fuser-interface\u002Fcontrols\u002Fcollectionview\u002Flayout)\n- [CollectionView selection](https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fmaui\u002Fuser-interface\u002Fcontrols\u002Fcollectionview\u002Fselection)\n- [CollectionView grouping](https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fmaui\u002Fuser-interface\u002Fcontrols\u002Fcollectionview\u002Fgrouping)\n- [CollectionView scrolling](https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fmaui\u002Fuser-interface\u002Fcontrols\u002Fcollectionview\u002Fscrolling)\n- [CollectionView EmptyView](https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fmaui\u002Fuser-interface\u002Fcontrols\u002Fcollectionview\u002Femptyview)\n","# CollectionView — .NET MAUI\n\n`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.\n\n## When to Use\n\n- Displaying a scrollable list or grid of data items\n- Binding a collection of objects to a templated item layout\n- Adding selection (single or multiple), grouping, or pull-to-refresh\n- Implementing infinite scroll \u002F incremental loading\n- Showing swipe actions on list items\n- Displaying an empty state when no data is available\n\n## When Not to Use\n\n- Static layouts with a fixed number of items — use `Grid` or `StackLayout` directly\n- Map pin lists — use the `Microsoft.Maui.Controls.Maps` NuGet package\n- Table-based data entry forms — use standard form controls\n- Simple text-only lists with no interaction — consider `BindableLayout` on a `StackLayout`\n\n## Scope Control — Answer Only What Was Asked\n\nThis skill is a **reference you consult**, not a checklist you apply. Most requests\nneed one or two sections from it. Pulling in the rest makes the answer worse.\n\n**Stop conditions — do NOT act when:**\n\n- **The user asked a narrow question.** Answer that question only. Do not append\n  grouping, swipe actions, empty views, snap points, or performance tips that\n  were not asked about.\n- **The user's existing code already works.** Do not rewrite working markup to\n  match the examples here. Point out a concrete defect; if there is none, say so\n  and answer the question that was asked.\n- **The change is stylistic.** Renaming, reordering attributes, or restructuring\n  a template that already behaves correctly is churn, not a fix.\n- **The control isn't `CollectionView`.** `CarouselView`, `BindableLayout`, and\n  `ListView`-in-maintenance code have different rules. Do not rewrite `ListView`\n  code the user did not ask about — but if they ask *which* control to use, or are\n  migrating from Xamarin.Forms, recommend `CollectionView` (see\n  [Migrating from ListView](#migrating-from-listview)).\n- **The problem is really a binding, DI, or navigation problem** that happens to\n  involve a list — defer to `maui-data-binding`, `maui-dependency-injection`, or\n  `maui-shell-navigation`.\n\n**The API sections below are a reference, not a checklist — offer them only when\nrelevant.** Four rules are non-negotiable, because violating them produces code that\ndoes not work or silently loses compile-time checking:\n\n1. Never use `ViewCell` as a `DataTemplate` root in `CollectionView`.\n2. Use `ObservableCollection\u003CT>` when the list mutates after first render.\n3. Mutate the bound collection on the UI thread.\n4. Set `x:DataType` on every `DataTemplate` (and on the page root) for compiled bindings.\n\nEverything else — sizing strategy, snap points, header\u002Ffooter, empty views — is\noptional and should be offered only when it addresses the user's actual problem.\n\n## Inputs\n\n- A data source (typically `ObservableCollection\u003CT>`) bound to `ItemsSource`\n- A `DataTemplate` defining how each item renders\n- Optional: layout configuration, selection mode, grouping model, empty view\n\n## Basic Setup\n\nA complete, copy-pasteable page. Two things are load-bearing: the `xmlns:models`\ndeclaration that every `x:DataType=\"models:Item\"` in this skill assumes, and the\n**root `x:DataType`** — without it the outer `ItemsSource` binding is not compiled:\n\n```xml\n\u003CContentPage xmlns=\"http:\u002F\u002Fschemas.microsoft.com\u002Fdotnet\u002F2021\u002Fmaui\"\n             xmlns:x=\"http:\u002F\u002Fschemas.microsoft.com\u002Fwinfx\u002F2009\u002Fxaml\"\n             xmlns:models=\"clr-namespace:MyApp.Models\"\n             xmlns:vm=\"clr-namespace:MyApp.ViewModels\"\n             x:DataType=\"vm:ItemsViewModel\"\n             x:Class=\"MyApp.ItemsPage\">\n    \u003CContentPage.BindingContext>\n        \u003Cvm:ItemsViewModel \u002F>\n    \u003C\u002FContentPage.BindingContext>\n    \u003CCollectionView ItemsSource=\"{Binding Items}\">\n        \u003CCollectionView.ItemTemplate>\n            \u003CDataTemplate x:DataType=\"models:Item\">\n                \u003CHorizontalStackLayout Padding=\"8\" Spacing=\"8\">\n                    \u003CImage Source=\"{Binding Icon}\" WidthRequest=\"40\" HeightRequest=\"40\" \u002F>\n                    \u003CLabel Text=\"{Binding Name}\" VerticalOptions=\"Center\" \u002F>\n                \u003C\u002FHorizontalStackLayout>\n            \u003C\u002FDataTemplate>\n        \u003C\u002FCollectionView.ItemTemplate>\n    \u003C\u002FCollectionView>\n\u003C\u002FContentPage>\n```\n\nLater snippets show only the `CollectionView` element. When you hand a snippet to a\nuser, include the matching `xmlns:` declaration for any prefix it uses, or the XAML\nwill not compile.\n\nThe inline `\u003CContentPage.BindingContext>` above keeps the example self-contained. In\nan app that uses dependency injection, register the ViewModel instead and assign it\nthrough constructor injection (`BindingContext = vm;`) — see the\n**maui-dependency-injection** skill.\n\n**Key rules:**\n\n- Bind `ItemsSource` to an `ObservableCollection\u003CT>` so the UI updates on add\u002Fremove.\n- Each item template root must be a `Layout` or `View` — **never use `ViewCell`**.\n- Always set `x:DataType` on `DataTemplate` for compiled bindings.\n\n## Layouts\n\nSet `ItemsLayout` to control arrangement. Default is `VerticalList`.\n\n| Layout | XAML value |\n|---|---|\n| Vertical list | `VerticalList` (default) |\n| Horizontal list | `HorizontalList` |\n| Vertical grid | `GridItemsLayout` with `Orientation=\"Vertical\"` |\n| Horizontal grid | `GridItemsLayout` with `Orientation=\"Horizontal\"` |\n\n### Grid Layout\n\n```xml\n\u003CCollectionView ItemsSource=\"{Binding Items}\">\n    \u003CCollectionView.ItemsLayout>\n        \u003CGridItemsLayout Orientation=\"Vertical\"\n                         Span=\"2\"\n                         VerticalItemSpacing=\"8\"\n                         HorizontalItemSpacing=\"8\" \u002F>\n    \u003C\u002FCollectionView.ItemsLayout>\n    \u003CCollectionView.ItemTemplate>\n        \u003CDataTemplate x:DataType=\"models:Item\">\n            \u003CBorder Padding=\"8\" StrokeThickness=\"0\">\n                \u003CVerticalStackLayout>\n                    \u003CImage Source=\"{Binding Image}\" HeightRequest=\"120\" Aspect=\"AspectFill\" \u002F>\n                    \u003CLabel Text=\"{Binding Name}\" FontAttributes=\"Bold\" \u002F>\n                \u003C\u002FVerticalStackLayout>\n            \u003C\u002FBorder>\n        \u003C\u002FDataTemplate>\n    \u003C\u002FCollectionView.ItemTemplate>\n\u003C\u002FCollectionView>\n```\n\n### Horizontal List\n\n```xml\n\u003CCollectionView ItemsSource=\"{Binding Items}\"\n                ItemsLayout=\"HorizontalList\" \u002F>\n```\n\n## Selection\n\n### Selection Mode\n\n| Mode | Property to bind | Binding mode |\n|---|---|---|\n| `None` | — | — |\n| `Single` | `SelectedItem` | `TwoWay` |\n| `Multiple` | `SelectedItems` | `OneWay` |\n\n```xml\n\u003CCollectionView ItemsSource=\"{Binding Items}\"\n                SelectionMode=\"Single\"\n                SelectedItem=\"{Binding CurrentItem, Mode=TwoWay}\"\n                SelectionChangedCommand=\"{Binding ItemSelectedCommand}\" \u002F>\n```\n\nFor `Multiple` selection, bind `SelectedItems` (type `IList\u003Cobject>`):\n\n```xml\n\u003CCollectionView SelectionMode=\"Multiple\"\n                SelectedItems=\"{Binding ChosenItems, Mode=OneWay}\" \u002F>\n```\n\n### Selected Visual State\n\nHighlight selected items using `VisualStateManager`:\n\n```xml\n\u003CCollectionView.ItemTemplate>\n    \u003CDataTemplate x:DataType=\"models:Item\">\n        \u003CGrid Padding=\"8\">\n            \u003CVisualStateManager.VisualStateGroups>\n                \u003CVisualStateGroup Name=\"CommonStates\">\n                    \u003CVisualState Name=\"Normal\">\n                        \u003CVisualState.Setters>\n                            \u003CSetter Property=\"BackgroundColor\" Value=\"Transparent\" \u002F>\n                        \u003C\u002FVisualState.Setters>\n                    \u003C\u002FVisualState>\n                    \u003CVisualState Name=\"Selected\">\n                        \u003CVisualState.Setters>\n                            \u003CSetter Property=\"BackgroundColor\"\n                                    Value=\"{AppThemeBinding Light={StaticResource Primary}, Dark={StaticResource PrimaryDark}}\" \u002F>\n                        \u003C\u002FVisualState.Setters>\n                    \u003C\u002FVisualState>\n                \u003C\u002FVisualStateGroup>\n            \u003C\u002FVisualStateManager.VisualStateGroups>\n            \u003CLabel Text=\"{Binding Name}\" \u002F>\n        \u003C\u002FGrid>\n    \u003C\u002FDataTemplate>\n\u003C\u002FCollectionView.ItemTemplate>\n```\n\n## Grouping\n\n1. Create a group class inheriting from `List\u003CT>`:\n\n```csharp\npublic class AnimalGroup : List\u003CAnimal>\n{\n    public string Name { get; }\n    public AnimalGroup(string name, List\u003CAnimal> animals) : base(animals)\n    {\n        Name = name;\n    }\n}\n```\n\n2. Bind to `ObservableCollection\u003CAnimalGroup>` and set `IsGrouped=\"True\"`:\n\n```xml\n\u003CCollectionView ItemsSource=\"{Binding AnimalGroups}\"\n                IsGrouped=\"True\">\n    \u003CCollectionView.GroupHeaderTemplate>\n        \u003CDataTemplate x:DataType=\"models:AnimalGroup\">\n            \u003CLabel Text=\"{Binding Name}\"\n                   FontAttributes=\"Bold\"\n                   BackgroundColor=\"{StaticResource Gray100}\"\n                   Padding=\"8\" \u002F>\n        \u003C\u002FDataTemplate>\n    \u003C\u002FCollectionView.GroupHeaderTemplate>\n    \u003CCollectionView.ItemTemplate>\n        \u003CDataTemplate x:DataType=\"models:Animal\">\n            \u003CLabel Text=\"{Binding Name}\" Padding=\"16,4\" \u002F>\n        \u003C\u002FDataTemplate>\n    \u003C\u002FCollectionView.ItemTemplate>\n\u003C\u002FCollectionView>\n```\n\n## Pull-to-Refresh\n\nWrap `CollectionView` in a `RefreshView`. Set `IsRefreshing` back to `false` when done:\n\n```xml\n\u003CRefreshView IsRefreshing=\"{Binding IsRefreshing}\"\n             Command=\"{Binding RefreshCommand}\">\n    \u003CCollectionView ItemsSource=\"{Binding Items}\" \u002F>\n\u003C\u002FRefreshView>\n```\n\n## Incremental Loading (Infinite Scroll)\n\n```xml\n\u003CCollectionView ItemsSource=\"{Binding Items}\"\n                RemainingItemsThreshold=\"5\"\n                RemainingItemsThresholdReachedCommand=\"{Binding LoadMoreCommand}\" \u002F>\n```\n\n> ⚠️ **Do NOT use with non-virtualizing layouts.** `LinearItemsLayout` and `GridItemsLayout` support virtualization. Using `BindableLayout` on a `StackLayout` as an alternative to `CollectionView` has no virtualization, which triggers infinite threshold-reached events.\n\n## SwipeView — Binding from Inside DataTemplate\n\nCommands inside a `DataTemplate` can't directly reach your ViewModel. Use `RelativeSource AncestorType`:\n\n```xml\n\u003CCollectionView.ItemTemplate>\n    \u003CDataTemplate x:DataType=\"models:Item\">\n        \u003CSwipeView>\n            \u003CSwipeView.RightItems>\n                \u003CSwipeItems>\n                    \u003CSwipeItem Text=\"Delete\"\n                               BackgroundColor=\"Red\"\n                               Command=\"{Binding BindingContext.DeleteCommand, Source={RelativeSource AncestorType={x:Type ContentPage}}}\"\n                               CommandParameter=\"{Binding}\" \u002F>\n                \u003C\u002FSwipeItems>\n            \u003C\u002FSwipeView.RightItems>\n            \u003CGrid Padding=\"8\">\n                \u003CLabel Text=\"{Binding Name}\" \u002F>\n            \u003C\u002FGrid>\n        \u003C\u002FSwipeView>\n    \u003C\u002FDataTemplate>\n\u003C\u002FCollectionView.ItemTemplate>\n```\n\n## EmptyView\n\nShown when `ItemsSource` is empty or null.\n\n```xml\n\u003CCollectionView ItemsSource=\"{Binding SearchResults}\"\n                EmptyView=\"No items found.\" \u002F>\n```\n\nFor a custom empty view, wrap in `ContentView`:\n\n```xml\n\u003CCollectionView ItemsSource=\"{Binding SearchResults}\">\n    \u003CCollectionView.EmptyView>\n        \u003CContentView>\n            \u003CVerticalStackLayout HorizontalOptions=\"Center\" VerticalOptions=\"Center\">\n                \u003CImage Source=\"empty_state.png\" WidthRequest=\"120\" \u002F>\n                \u003CLabel Text=\"Nothing here yet\" HorizontalTextAlignment=\"Center\" \u002F>\n            \u003C\u002FVerticalStackLayout>\n        \u003C\u002FContentView>\n    \u003C\u002FCollectionView.EmptyView>\n\u003C\u002FCollectionView>\n```\n\n## Headers and Footers\n\n```xml\n\u003CCollectionView ItemsSource=\"{Binding Items}\">\n    \u003CCollectionView.Header>\n        \u003CLabel Text=\"Header\" FontAttributes=\"Bold\" Padding=\"8\" \u002F>\n    \u003C\u002FCollectionView.Header>\n    \u003CCollectionView.Footer>\n        \u003CLabel Text=\"Footer\" FontAttributes=\"Italic\" Padding=\"8\" \u002F>\n    \u003C\u002FCollectionView.Footer>\n\u003C\u002FCollectionView>\n```\n\nUse `HeaderTemplate` \u002F `FooterTemplate` when headers or footers are data-bound.\n\n## Scrolling\n\n### ScrollTo\n\nProgrammatically scroll by index or item:\n\n```csharp\n\u002F\u002F Scroll to index\ncollectionView.ScrollTo(index: 10, position: ScrollToPosition.Center, animate: true);\n\n\u002F\u002F Scroll to item\ncollectionView.ScrollTo(item: myItem, position: ScrollToPosition.MakeVisible, animate: true);\n```\n\n| ScrollToPosition | Behavior |\n|---|---|\n| `MakeVisible` | Scrolls just enough to make the item visible |\n| `Start` | Scrolls item to the start of the viewport |\n| `Center` | Scrolls item to the center of the viewport |\n| `End` | Scrolls item to the end of the viewport |\n\n### Snap Points\n\n```xml\n\u003CCollectionView.ItemsLayout>\n    \u003CLinearItemsLayout Orientation=\"Horizontal\"\n                       SnapPointsType=\"MandatorySingle\"\n                       SnapPointsAlignment=\"Center\" \u002F>\n\u003C\u002FCollectionView.ItemsLayout>\n```\n\n- `SnapPointsType`: `None`, `Mandatory`, `MandatorySingle`\n- `SnapPointsAlignment`: `Start`, `Center`, `End`\n\n## Migrating from ListView\n\n`ListView` still compiles, but **as of .NET 10** it is marked `[Obsolete]`\n(\"*ListView is deprecated. Please use CollectionView instead.*\"). It is **not**\nobsolete on .NET 9 and earlier, so check the project's target framework before\ndescribing it as deprecated. **If the user asks\nwhich control to use, or is migrating from Xamarin.Forms, recommend\n`CollectionView`** — it is faster, needs no `ViewCell`, and supports flexible\nlayouts. What to avoid is silently rewriting `ListView` code the user did not ask\nyou to touch.\n\n| `ListView` | `CollectionView` equivalent |\n|---|---|\n| `ViewCell` template root | Any `View`\u002F`Layout` root — **`ViewCell` is not supported** |\n| `ItemSelected` event | `SelectionChanged` event, or `SelectionChangedCommand` |\n| `ItemTapped` event | A `TapGestureRecognizer` in the item template — `SelectionChanged` only fires when the selection *changes*, so it will not re-fire on tapping the already-selected item |\n| `IsPullToRefreshEnabled` + `Refreshing` | Wrap the `CollectionView` in a `RefreshView` |\n| `IsGroupingEnabled` | `IsGrouped` |\n| `HasUnevenRows=\"True\"` | Default `ItemSizingStrategy=\"MeasureAllItems\"` |\n| `RowHeight` (fixed height) | Set the height in the item template. `MeasureFirstItem` only reuses the first item's measured size — it is not an explicit row height |\n| `SeparatorVisibility` \u002F `SeparatorColor` | **No equivalent** — draw a `BoxView`\u002F`Border` in the item template |\n\nThe missing separator API is the most common migration surprise: `CollectionView`\nhas no built-in separators, so add one to the template yourself.\n\n## Performance Tips\n\nApply these only when the user reports a performance problem or explicitly asks\nabout performance — they are not a default checklist.\n\n- **Use `MeasureFirstItem`** for uniform item sizes — significantly faster than the default\n  `MeasureAllItems`, which measures every item individually. Set it on the `CollectionView`\n  itself (it is declared on `StructuredItemsView`), **not** on `LinearItemsLayout` \u002F\n  `GridItemsLayout`:\n  ```xml\n  \u003CCollectionView ItemsSource=\"{Binding Items}\"\n                  ItemSizingStrategy=\"MeasureFirstItem\">\n      \u003CCollectionView.ItemTemplate>\n          \u003CDataTemplate x:DataType=\"models:Item\">\n              \u003CGrid Padding=\"8\" ColumnDefinitions=\"44,*\" ColumnSpacing=\"8\">\n                  \u003CImage WidthRequest=\"44\" HeightRequest=\"44\" \u002F>\n                  \u003CLabel Grid.Column=\"1\" Text=\"{Binding Name}\" VerticalOptions=\"Center\" \u002F>\n              \u003C\u002FGrid>\n          \u003C\u002FDataTemplate>\n      \u003C\u002FCollectionView.ItemTemplate>\n  \u003C\u002FCollectionView>\n  ```\n  **When `MeasureFirstItem` is the wrong choice** — keep the default `MeasureAllItems` if:\n  - Items vary in height (wrapping text, optional rows, images of differing aspect) — the\n    first item's size is applied to all, so the rest are clipped or stretched.\n  - A `DataTemplateSelector` returns different templates — the first item won't represent\n    the others.\n  - The first item is atypical (a header-like or \"featured\" row) — every item inherits its\n    size. Fixing this by reordering data is a smell; use `MeasureAllItems` instead.\n  - Item size depends on runtime data that isn't loaded yet when the first item is measured.\n- **Use `ObservableCollection\u003CT>` when the list mutates after first render.** It implements\n  `INotifyCollectionChanged`, so in-place `Add`\u002F`Remove`\u002F`Insert` update the UI incrementally.\n  A `List\u003CT>` is fine for a list that never changes after it is bound. Note that *replacing*\n  `ItemsSource` re-renders everything regardless of the collection type — so mutate the bound\n  collection in place rather than reassigning it.\n- **Update collections on the UI thread** — `MainThread.BeginInvokeOnMainThread(() => Items.Add(item))`.\n\n## Common Pitfalls\n\n| Issue | Fix |\n|---|---|\n| UI doesn't update when items change | Use `ObservableCollection\u003CT>`, not `List\u003CT>`. |\n| App crashes or blank items | **Never use `ViewCell`** — use `Grid`, `StackLayout`, or any `View` as template root. |\n| Items disappear or layout breaks | Always update `ItemsSource` and the collection on the **UI thread** (`MainThread.BeginInvokeOnMainThread`). |\n| Incremental loading fires endlessly | Don't use `StackLayout` as layout; use `LinearItemsLayout` or `GridItemsLayout`. |\n| EmptyView doesn't render correctly | Wrap custom empty views in `ContentView`. |\n| Poor scroll performance | Use `MeasureFirstItem` sizing strategy for uniform item sizes. |\n| `ItemSizingStrategy` doesn't compile | It is declared on `StructuredItemsView` — set it on `\u003CCollectionView>`, not on `\u003CLinearItemsLayout>` \u002F `\u003CGridItemsLayout>`. |\n| Items clipped or stretched | `MeasureFirstItem` assumes uniform item size. Use the default `MeasureAllItems` for variable-height items. |\n| Selected state not visible | Add `VisualState Name=\"Selected\"` to the item template root element. |\n| Binding errors in SwipeView commands | Use `RelativeSource AncestorType` to reach the ViewModel from inside the item template. |\n\n## Validation\n\nBefore returning CollectionView markup you wrote or edited, confirm:\n\n- [ ] The `DataTemplate` root is a `View`\u002F`Layout` — **not** `ViewCell`.\n- [ ] `DataTemplate` declares `x:DataType` for compiled bindings.\n- [ ] `ItemsSource` is bound to `ObservableCollection\u003CT>` if the list mutates.\n- [ ] `ItemSizingStrategy` (if used) is on `\u003CCollectionView>`, not on the layout.\n- [ ] `Multiple` selection binds `SelectedItems`; `Single` binds `SelectedItem` (`TwoWay`).\n- [ ] `RefreshView.IsRefreshing` is set back to `false` when the refresh completes.\n- [ ] The answer covers **only** what the user asked — no unrequested sections.\n\n## References\n\n- [CollectionView overview](https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fmaui\u002Fuser-interface\u002Fcontrols\u002Fcollectionview\u002F)\n- [CollectionView layout](https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fmaui\u002Fuser-interface\u002Fcontrols\u002Fcollectionview\u002Flayout)\n- [CollectionView selection](https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fmaui\u002Fuser-interface\u002Fcontrols\u002Fcollectionview\u002Fselection)\n- [CollectionView grouping](https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fmaui\u002Fuser-interface\u002Fcontrols\u002Fcollectionview\u002Fgrouping)\n- [CollectionView scrolling](https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fmaui\u002Fuser-interface\u002Fcontrols\u002Fcollectionview\u002Fscrolling)\n- [CollectionView EmptyView](https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fmaui\u002Fuser-interface\u002Fcontrols\u002Fcollectionview\u002Femptyview)\n",{"name":5,"license":15,"description":24},"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\u002Fbinding questions that merely happen to mention a list (use maui-data-binding).\n","main","30954af1dcd1a74b63f05deb2e2c41e5ecae4a82","10-Mobile-Development\u002Fmaui-collectionview","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack","https:\u002F\u002Fgithub.com\u002Fitsmejay18","2026-09-18 16:06:36",{"source":8,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add itsmejay18\u002FAI-Skills-for-My-Development-Stack --skill maui-collectionview",{"tool":37,"command":38},"bunx","bunx skills add itsmejay18\u002FAI-Skills-for-My-Development-Stack --skill maui-collectionview",{"tool":40,"command":41},"pnpm","pnpm dlx skills add itsmejay18\u002FAI-Skills-for-My-Development-Stack --skill maui-collectionview","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F10-Mobile-Development\u002Fmaui-collectionview\u002FSKILL.md",true,[45],{"path":46,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":49,"sourceHtmlUrl":50},"references\u002Fcollectionview-api.md","REFERENCE","参考文档",7365,"https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F10-Mobile-Development\u002Fmaui-collectionview\u002Freferences\u002Fcollectionview-api.md",[52,59,66,73,80,87],{"skillNo":53,"name":54,"nameZh":6,"description":55,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":56,"categories":57,"keywords":58,"publishedAt":19},"01M7D2RKBHPZ3E1RNN5DWHT550","vectorization","Design, implement, optimize, and review SIMD code in .NET. USE FOR: vectorizing scalar loops with TensorPrimitives, Vector64\u002F128\u002F256\u002F512, or platform hardware intrinsics; reviewing existing SIMD code, including Vector\u003CT>, for contract equivalence, tail handling, memory safety, portability, fallbacks, and measured performance. DO NOT USE FOR: performance work unrelated to SIMD or vectorization.","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F20-Performance-Optimization\u002Fvectorization\u002FSKILL.md",[],[],{"skillNo":60,"name":61,"nameZh":6,"description":62,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":63,"categories":64,"keywords":65,"publishedAt":19},"01M7D2RDJ7RN3QK8GJR0QTER1D","resolve-project-references","Guide for interpreting ResolveProjectReferences time in MSBuild performance summaries. Activate when ResolveProjectReferences appears as the most expensive target and developers are trying to optimize it directly. Explains that the reported time includes wait time for dependent project builds and is misleading. Guides users to focus on task self-time instead. Do not activate for general build performance -- use build-perf-diagnostics instead.","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F20-Performance-Optimization\u002Fresolve-project-references\u002FSKILL.md",[],[],{"skillNo":67,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":19},"01M7D2R1H2GTNZYHG9YRX3JDQW","optimizing-ef-core-queries","Optimize and improve the performance of slow Entity Framework Core (EF Core) queries: make them generate less SQL, make fewer database round-trips, and return results faster. Use whenever an EF Core or DbContext query or data-access path is slow or should be made faster — whether or not EF Core owns the database schema. For EF Core, not Dapper or raw ADO.NET.","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F20-Performance-Optimization\u002Foptimizing-ef-core-queries\u002FSKILL.md",[],[],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":19},"01M7D2QREG04W1YT0NEBHEW5C9","microbenchmarking","Activate this skill when BenchmarkDotNet (BDN) is involved in the task — creating, running, configuring, or reviewing BDN benchmarks. Also activate when microbenchmarking .NET code would be useful and BenchmarkDotNet is the likely tool. Consider activating when answering a .NET performance question requires measurement and BenchmarkDotNet may be needed. Covers microbenchmark design, BDN configuration and project setup, how to run BDN microbenchmarks efficiently and effectively, and using BDN for side-by-side performance comparisons. Do NOT use for profiling\u002Ftracing .NET code (dotnet-trace, PerfView), production telemetry, or load\u002Fstress testing (Crank, k6).","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F20-Performance-Optimization\u002Fmicrobenchmarking\u002FSKILL.md",[],[],{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":19},"01M7D2QGE175XWPZVACVH2868Z","incremental-build","Guide for optimizing MSBuild incremental builds. USE FOR: builds slower than expected on subsequent runs, 'nothing changed but it rebuilds anyway', diagnosing why targets re-execute unnecessarily, fixing broken no-op builds. Covers 8 common causes: missing Inputs\u002FOutputs on custom targets, volatile properties in output paths (timestamps\u002FGUIDs), file writes outside tracked Outputs, missing FileWrites registration, glob changes, Visual Studio Fast Up-to-Date Check (FUTDC) issues. Key diagnostic: look for 'Building target completely' vs 'Skipping target' in binlog. DO NOT USE FOR: first-time build slowness (use build-perf-baseline), parallelism issues (use build-parallelism), evaluation-phase slowness (use eval-performance), non-MSBuild build systems.","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F20-Performance-Optimization\u002Fincremental-build\u002FSKILL.md",[],[],{"skillNo":88,"name":89,"nameZh":6,"description":90,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":91,"categories":92,"keywords":93,"publishedAt":19},"01M7D2Q1DQTC6K49R73WQTTPSB","eval-performance","Guide for diagnosing and improving MSBuild project evaluation performance. USE FOR: builds slow before any compilation starts, high evaluation time in binlog analysis, expensive glob patterns walking large directories (node_modules, .git, bin\u002Fobj), deep import chains (>20 levels), preprocessed output >10K lines indicating heavy evaluation, property functions with file I\u002FO ($([System.IO.File]::ReadAllText(...))), multiple evaluations per project. Covers the 5 MSBuild evaluation phases, glob optimization via DefaultItemExcludes, import chain analysis with \u002Fpp preprocessing. DO NOT USE FOR: compilation-time slowness (use build-perf-diagnostics), incremental build issues (use incremental-build), non-MSBuild build systems.","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F20-Performance-Optimization\u002Feval-performance\u002FSKILL.md",[],[]]