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

Android Jetpack Compose Windsurf rules

Windsurf rules for Android apps in Kotlin and Jetpack Compose: state hoisting, ViewModel + StateFlow, Material 3, navigation, Hilt and Compose UI tests.

WindsurfAndroid / Kotlin

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

Get the best new AI prompts every week

One short email a week: the best new prompts and rules for ChatGPT, Claude, Gemini, Midjourney, Cursor and more, plus what changed in the tools. Free, unsubscribe anytime.

Finishes on our newsletter page at beehiiv (opens in a new tab). Or subscribe directly.