Home › .NET MAUI › .NET MAUI rules

.NET MAUI rules

Cursor rules for .NET MAUI apps on .NET 10: MVVM with CommunityToolkit.Mvvm, Shell navigation, compiled bindings, DI.

Cursor.NET MAUI

How to use

Save this as .cursor/rules/maui.mdc in your repository root, commit it, and your agent will pick it up automatically. Edit the commands to match your project.

Note: Review and test before use. Provided as is, without warranty. See Terms.

.cursor/rules/maui.mdcDownload  
---
description: .NET MAUI conventions
globs: ["**/*.cs","**/*.xaml"]
alwaysApply: false
---

# .NET MAUI (.NET 10)

- MVVM with `CommunityToolkit.Mvvm`: view models are `partial` classes deriving from `ObservableObject`, using `[ObservableProperty]` on partial properties and `[RelayCommand]` for commands (async commands get cancellation and `IsRunning`).
- No logic in code-behind beyond wiring; pages receive their view model through constructor DI.
- Register pages, view models, and services in `MauiProgram.CreateMauiApp()` (`AddTransient<OrdersPage>()`, `AddSingleton<IApiClient, ApiClient>()`).
- Every XAML page/template sets `x:DataType` so bindings are compiled and checked.
- Navigation with Shell routes (`Routing.RegisterRoute`, `await Shell.Current.GoToAsync("orders/detail", new Dictionary<string, object> { ["Order"] = order })`); receive with `IQueryAttributable` or `[QueryProperty]`.
- Lists use `CollectionView` (not `ListView`) with `DataTemplate`s; avoid nested scrolling.
- UI updates from background threads via `MainThread.BeginInvokeOnMainThread` only when needed; keep I/O async.
- Platform code in `Platforms/<platform>/` or partial classes; check permissions with `Permissions.RequestAsync<T>()`.
- Secrets in `SecureStorage`, settings in `Preferences`. HTTP via a typed `HttpClient` service.
- Styles and colors in `Resources/Styles`; support light/dark with `AppThemeBinding`.

## Done when
`dotnet build -f net10.0-android` (and the iOS/Windows targets you can build) succeeds with no XAML binding warnings, and unit tests for view models pass.

More: all .NET MAUI rules · all Cursor rules

Related rules

Flutter + Riverpod rules

Cursor rules for Flutter 3 apps using Riverpod 3 with code generation, go_router, and widget tests.

CursorFlutter

React Native + Expo rules

Cursor rules for Expo Router apps with TypeScript, NativeWind and TanStack Query.

CursorReact Native / Expo

Flutter AGENTS.md

AGENTS.md for Flutter apps with Riverpod, go_router and clean feature-first structure.

AGENTS.mdFlutter

Ionic + Capacitor AGENTS.md

AGENTS.md for Ionic 8 apps with Capacitor (Angular, React, or Vue): native plugins, platform sync, and mobile UX rules.

AGENTS.mdIonic / Capacitor

Kotlin Multiplatform + Compose Multiplatform CLAUDE.md

CLAUDE.md for Kotlin Multiplatform apps sharing UI with Compose Multiplatform across Android, iOS, desktop, and web.

Claude Code (CLAUDE.md)Kotlin Multiplatform

Kotlin Multiplatform Copilot path instructions

Path-specific Copilot instructions for Kotlin Multiplatform modules: commonMain first, expect/actual, and coroutines.

GitHub CopilotKotlin Multiplatform

Get new rules weekly

One email a week: fresh rule files, agent tips, and what's changing in Cursor, Claude Code and Copilot. Free, unsubscribe anytime.

Opens the Rulestack Newsletter on beehiiv in a new tab. Or subscribe directly on beehiiv.