MAUI Controls Deep Dive
Use this skill when the user is already working with MAUI controls and needs
details beyond basic layout guidance. Keep control choices aligned with current
MAUI APIs.
Response Checklist
- For list scenarios, prefer
CollectionView with EmptyView,
RemainingItemsThreshold, and stable AutomationId hooks.
- For edge-to-edge scenarios, call out
.NET 10 SafeAreaEdges values.
- For
GraphicsView, keep IDrawable.Draw hot-path guidance and add semantic
alternatives (SemanticProperties / accessible companion UI).
Workflow
- Inspect the target framework and whether the UI is XAML, C# Markup, or another
MAUI UI style.
- Identify the control area:
CollectionView, safe area, gestures, animations,
or GraphicsView.
- Apply the focused guidance below. Route broad accessibility audits to
maui-accessibility; for GraphicsView-specific semantics, apply
SemanticProperties and AutomationId directly (see GraphicsView section).
Route performance profiling to maui-performance.
- Validate the control on the intended device sizes and platforms.
CollectionView
Use CollectionView for repeated data and let it own scrolling:
- Do not wrap it in
ScrollView.
- Use
EmptyView, header/footer, and surrounding Grid rows for non-item UI.
- Use
RemainingItemsThreshold / RemainingItemsThresholdReachedCommand for
incremental loading.
- Use
SelectionMode, SelectedItem, and SelectionChangedCommand instead of
tap gestures on item roots when selection is the intent.
- Keep item templates lightweight. Avoid nested layouts and expensive converters
in large lists.
- Prefer stable
AutomationId values on the list and critical item controls.
- For .NET 10 iOS/Mac Catalyst behavior, check current handler guidance before
opting into or reverting CollectionView handlers.
Example state shell:
<Grid RowDefinitions="Auto,*">
<ActivityIndicator
AutomationId="orders-loading"
IsRunning="{Binding IsBusy}"
IsVisible="{Binding IsBusy}" />
<CollectionView
Grid.Row="1"
AutomationId="orders-list"
ItemsSource="{Binding Orders}"
RemainingItemsThreshold="5"
RemainingItemsThresholdReachedCommand="{Binding LoadMoreCommand}">
<CollectionView.EmptyView>
<Label
AutomationId="orders-empty"
Text="No orders found." />
</CollectionView.EmptyView>
</CollectionView>
</Grid>
Safe Areas
For .NET 10+ safe-area work, use SafeAreaEdges on the root container instead
of hard-coded iOS-only padding:
| Value |
Effect |
SafeAreaEdges.Container |
Insets only the device bezel/notch boundary |
SafeAreaEdges.SoftInput |
Also avoids the on-screen keyboard |
SafeAreaEdges.All |
All edges including status bar and navigation areas |
<!-- XAML: apply on the outermost layout that should respect device edges -->
<Grid SafeAreaEdges="Container">
...
</Grid>
// C# Markup
new Grid { SafeAreaEdges = SafeAreaEdges.Container }
Keep safe-area behavior declarative. Test with notches, rounded corners, desktop
title bars, and soft keyboard scenarios when the page uses edge-to-edge layout.
If the MAUI version is unknown, use maui-current-apis before changing APIs.
Gestures
- Use
TapGestureRecognizer for click/tap. Do not use removed or obsolete
click gesture APIs.
- Use
PointerGestureRecognizer for hover/desktop pointer affordances.
- Use
PanGestureRecognizer, SwipeGestureRecognizer, and
PinchGestureRecognizer only where the gesture maps to an obvious UI action.
- Do not attach competing gestures to deeply nested controls without testing
hit-testing and scrolling interactions.
- Preserve accessibility alternatives: commands, buttons, menu items, keyboard
accelerators, or semantic descriptions as appropriate.
Animations
- Prefer built-in async animation helpers such as
FadeTo, ScaleTo,
TranslateTo, and RotateTo for view animations.
- Await or coordinate animations so state changes do not race.
- Cancel or ignore stale animations when view models unload or commands rerun.
- Avoid animation-only feedback for important state; expose semantic state and
visual states too.
- Keep list item animations modest; animating many recycled cells can hurt
scrolling performance.
GraphicsView
Use GraphicsView for custom drawing, charts, signatures, or lightweight
visualizations:
- Put drawing code in an
IDrawable.
- Treat
Draw(ICanvas canvas, RectF dirtyRect) as a hot path: avoid allocations,
blocking I/O, async calls, and service lookups.
- Store state outside the drawable and call
Invalidate() when state changes.
- Handle pointer/touch input at the view or page layer and translate it to
drawing state.
- For important information in the drawing, provide accessible alternatives
outside the canvas: wrap the
GraphicsView alongside a Label or use
SemanticProperties.Description on the view so screen readers announce it.
AutomationId on the GraphicsView enables UI-test targeting.
- Use
SemanticScreenReader.Announce for dynamic changes that must be audible.
- If drawing stutters or allocates heavily, consult
maui-performance.
Validation Checklist
CollectionView owns its scrolling and has empty/loading behavior where data
can be absent.
- Safe-area code matches the detected MAUI version and target platforms.
- Gestures have accessible alternatives for critical actions.
- Animations cannot leave the UI in stale state after cancellation or navigation.
GraphicsView drawing is allocation-conscious and exposes important content
outside the canvas.
1---2name: maui-controls-deep-dive3description: Apply advanced MAUI control guidance. USE FOR: `CollectionView` incremental loading, `RemainingItemsThreshold`, `EmptyView`, `AutomationId`, avoiding `ScrollView` wrappers, .NET 10 `SafeAreaEdges`, `GraphicsView`/`IDrawable`, gestures, animations. DO NOT USE FOR: general layout, full accessibility, profiling, handlers.4---56# MAUI Controls Deep Dive78Use this skill when the user is already working with MAUI controls and needs9details beyond basic layout guidance. Keep control choices aligned with current10MAUI APIs.1112## Response Checklist1314- For list scenarios, prefer `CollectionView` with `EmptyView`,15 `RemainingItemsThreshold`, and stable `AutomationId` hooks.16- For edge-to-edge scenarios, call out `.NET 10` `SafeAreaEdges` values.17- For `GraphicsView`, keep `IDrawable.Draw` hot-path guidance and add semantic18 alternatives (`SemanticProperties` / accessible companion UI).1920## Workflow21221. Inspect the target framework and whether the UI is XAML, C# Markup, or another23 MAUI UI style.242. Identify the control area: `CollectionView`, safe area, gestures, animations,25 or `GraphicsView`.263. Apply the focused guidance below. Route broad accessibility audits to27 `maui-accessibility`; for GraphicsView-specific semantics, apply28 `SemanticProperties` and `AutomationId` directly (see GraphicsView section).29 Route performance profiling to `maui-performance`.304. Validate the control on the intended device sizes and platforms.3132## CollectionView3334Use `CollectionView` for repeated data and let it own scrolling:3536- Do not wrap it in `ScrollView`.37- Use `EmptyView`, header/footer, and surrounding `Grid` rows for non-item UI.38- Use `RemainingItemsThreshold` / `RemainingItemsThresholdReachedCommand` for39 incremental loading.40- Use `SelectionMode`, `SelectedItem`, and `SelectionChangedCommand` instead of41 tap gestures on item roots when selection is the intent.42- Keep item templates lightweight. Avoid nested layouts and expensive converters43 in large lists.44- Prefer stable `AutomationId` values on the list and critical item controls.45- For .NET 10 iOS/Mac Catalyst behavior, check current handler guidance before46 opting into or reverting CollectionView handlers.4748Example state shell:4950```xml51<Grid RowDefinitions="Auto,*">52 <ActivityIndicator53 AutomationId="orders-loading"54 IsRunning="{Binding IsBusy}"55 IsVisible="{Binding IsBusy}" />5657 <CollectionView58 Grid.Row="1"59 AutomationId="orders-list"60 ItemsSource="{Binding Orders}"61 RemainingItemsThreshold="5"62 RemainingItemsThresholdReachedCommand="{Binding LoadMoreCommand}">63 <CollectionView.EmptyView>64 <Label65 AutomationId="orders-empty"66 Text="No orders found." />67 </CollectionView.EmptyView>68 </CollectionView>69</Grid>70```7172## Safe Areas7374For .NET 10+ safe-area work, use `SafeAreaEdges` on the root container instead75of hard-coded iOS-only padding:7677| Value | Effect |78|---|---|79| `SafeAreaEdges.Container` | Insets only the device bezel/notch boundary |80| `SafeAreaEdges.SoftInput` | Also avoids the on-screen keyboard |81| `SafeAreaEdges.All` | All edges including status bar and navigation areas |8283```xml84<!-- XAML: apply on the outermost layout that should respect device edges -->85<Grid SafeAreaEdges="Container">86 ...87</Grid>88```8990```csharp91// C# Markup92new Grid { SafeAreaEdges = SafeAreaEdges.Container }93```9495Keep safe-area behavior declarative. Test with notches, rounded corners, desktop96title bars, and soft keyboard scenarios when the page uses edge-to-edge layout.97If the MAUI version is unknown, use `maui-current-apis` before changing APIs.9899## Gestures100101- Use `TapGestureRecognizer` for click/tap. Do not use removed or obsolete102 click gesture APIs.103- Use `PointerGestureRecognizer` for hover/desktop pointer affordances.104- Use `PanGestureRecognizer`, `SwipeGestureRecognizer`, and105 `PinchGestureRecognizer` only where the gesture maps to an obvious UI action.106- Do not attach competing gestures to deeply nested controls without testing107 hit-testing and scrolling interactions.108- Preserve accessibility alternatives: commands, buttons, menu items, keyboard109 accelerators, or semantic descriptions as appropriate.110111## Animations112113- Prefer built-in async animation helpers such as `FadeTo`, `ScaleTo`,114 `TranslateTo`, and `RotateTo` for view animations.115- Await or coordinate animations so state changes do not race.116- Cancel or ignore stale animations when view models unload or commands rerun.117- Avoid animation-only feedback for important state; expose semantic state and118 visual states too.119- Keep list item animations modest; animating many recycled cells can hurt120 scrolling performance.121122## GraphicsView123124Use `GraphicsView` for custom drawing, charts, signatures, or lightweight125visualizations:126127- Put drawing code in an `IDrawable`.128- Treat `Draw(ICanvas canvas, RectF dirtyRect)` as a hot path: avoid allocations,129 blocking I/O, async calls, and service lookups.130- Store state outside the drawable and call `Invalidate()` when state changes.131- Handle pointer/touch input at the view or page layer and translate it to132 drawing state.133- For important information in the drawing, provide accessible alternatives134 outside the canvas: wrap the `GraphicsView` alongside a `Label` or use135 `SemanticProperties.Description` on the view so screen readers announce it.136 `AutomationId` on the `GraphicsView` enables UI-test targeting.137- Use `SemanticScreenReader.Announce` for dynamic changes that must be audible.138- If drawing stutters or allocates heavily, consult `maui-performance`.139140## Validation Checklist141142- `CollectionView` owns its scrolling and has empty/loading behavior where data143 can be absent.144- Safe-area code matches the detected MAUI version and target platforms.145- Gestures have accessible alternatives for critical actions.146- Animations cannot leave the UI in stale state after cancellation or navigation.147- `GraphicsView` drawing is allocation-conscious and exposes important content148 outside the canvas.