Aller au contenu
Skillpedia
Applis mobiles5.8k · #14588

maui-shell-navigation

Ce qu’il fait

Cette skill guide la navigation entre pages dans les apps .NET MAUI avec Shell, y compris les onglets, les menus latéraux et les routes entre pages. Elle s'adresse aux développeurs qui construisent la structure de navigation d'une app MAUI.

Quand l’utiliser

  • ✓Quand vous avez besoin d'onglets ou d'un menu latéral pour la structure principale d'une app MAUI.
  • ✓Quand vous voulez passer d'une page à l'autre dans le code avec une route.
  • ✓Quand vous voulez demander confirmation à l'utilisateur avant de quitter une page avec des modifications non enregistrées.

Lien du skill

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

Copiez-le et collez-le dans votre IA (Claude, ChatGPT ou Cursor) en lui demandant de suivre les instructions.

Comment l’utiliser

Le plus simple : copiez le message et collez-le dans votre IA. Elle lit le skill et suit les instructions.

Message prêt à coller

Utilise ce skill pour m’aider : https://github.com/dotnet/skills/blob/main/plugins/dotnet-maui/skills/maui-shell-navigation/SKILL.md Lis le fichier SKILL.md de ce lien et suis ses instructions pour ma tâche.
Envie que votre IA trouve seule des skills comme celui-ci ?Installez le MCP gratuit de Skillpedia : une ligne, et elle cherche parmi 15 000+ skills avant chaque tâche.Installer en 1 minute →

Exemple de demande à votre IA

“Mets en place la navigation Shell pour mon app MAUI avec trois onglets et une page de détail qui s'ouvre depuis la liste.”

5 nouveaux skills par semaine. 1 minute de lecture.

Comment ça marche

L'agent définit la structure du shell dans son fichier XAML, enregistre les routes des pages de détail et utilise la navigation par routes pour passer d'une page à l'autre, les données étant transmises en paramètres.

Contenu technique (SKILL.md original)

Texte original de l’auteur, en anglais, directement depuis GitHub.

.NET MAUI Shell Navigation

Implement page navigation in .NET MAUI apps using Shell. Shell provides URI-based navigation, a flyout menu, tab bars, and a four-level visual hierarchy — all configured declaratively in XAML.

When to Use

  • Setting up top-level app navigation with tabs or a flyout menu
  • Navigating between pages programmatically with GoToAsync
  • Passing data between pages via query parameters or object parameters
  • Registering detail-page routes for push navigation
  • Guarding navigation with confirmation dialogs (e.g., unsaved changes)
  • Customizing back button behavior per page

When Not to Use

  • Deep linking from external URLs or app links — see .NET MAUI deep linking docs
  • Data binding on navigation target pages — use maui-data-binding
  • Dependency injection for pages and view models — use maui-dependency-injection
  • Apps using NavigationPage without Shell (different navigation API)

Inputs

  • A .NET MAUI project with AppShell.xaml as the root shell
  • Pages (ContentPage) to navigate between
  • Route names for detail pages not in the visual hierarchy

Rules That Change the Answer

These are the Shell-specific decisions that are easy to get wrong. Apply them whenever they are relevant to what the user asked.

Situation Do this Not this
Declaring pages in AppShell.xaml With xmlns:views="clr-namespace:MyApp.Views" declared: <ShellContent ContentTemplate="{DataTemplate views:MyPage}" /> — the page is created on first navigation <ShellContent><views:MyPage /></ShellContent>, which constructs every page at startup
Navigating to a page not in the visual hierarchy Routing.RegisterRoute("details", typeof(DetailsPage)) first Calling GoToAsync("details") unregistered — it throws at runtime
Receiving navigation parameters Implement IQueryAttributable on the ViewModel Implementing it on the Page, which splits state from the BindingContext
Passing a whole object ShellNavigationQueryParameters Serialising the object into the query string
Any GoToAsync call await it Fire-and-forget — exceptions are swallowed and navigation races
Confirming before back navigation ShellNavigatingEventArgs.GetDeferral() … deferral.Complete() Blocking synchronously on the dialog task
Detecting back navigation Check e.Source == ShellNavigationSource.Pop Assuming every navigation is a back action

Do not propose NavigationPage / PushAsync solutions for a Shell app, and do not restructure a working AppShell hierarchy unless the user asked.

Answer narrowly, but completely. Staying on topic does not mean being terse. When you show a navigation change, include the pieces needed to run it: the AppShell.xaml markup and the Routing.RegisterRoute call, or the GoToAsync call and the receiving IQueryAttributable / [QueryProperty] code. Where two approaches are both valid (query string vs ShellNavigationQueryParameters), show both and say when each fits — a single snippet the user still has to complete is a worse answer.

Shell Visual Hierarchy

Shell uses a four-level hierarchy. Each level wraps the one below it:

Shell
 ├── FlyoutItem / TabBar          (top-level grouping)
 │    ├── Tab                     (bottom-tab grouping)
 │    │    ├── ShellContent        (page slot → ContentPage)
 │    │    └── ShellContent        (multiple = top tabs)
 │    └── Tab
 └── FlyoutItem / TabBar
  • FlyoutItem — appears in the flyout menu; contains Tab children
  • TabBar — bottom tab bar with no flyout entry
  • Tab — groups ShellContent; multiple children produce top tabs
  • ShellContent — each points to a ContentPage

Implicit Conversion

You can omit intermediate wrappers. Shell auto-wraps:

You write Shell creates
ShellContent only FlyoutItem > Tab > ShellContent
Tab only FlyoutItem > Tab
ShellContent in TabBar TabBar > Tab > ShellContent

Workflow: Set Up AppShell

  1. Define AppShell.xaml inheriting from Shell
  2. Add FlyoutItem or TabBar elements for top-level navigation
  3. Add Tab elements for bottom tabs; nest multiple ShellContent for top tabs
  4. **Always use `Content
Questions fréquentes

Qu'est-ce que Shell ?

Shell est la structure de navigation intégrée de .NET MAUI, avec onglets, menus latéraux et routes.

Peut-on transmettre des données à une page ?

Oui. Les données peuvent passer par des paramètres de requête ou des paramètres d'objet.

Couvre-t-elle les liens profonds ?

Non. Les liens profonds venant de liens externes sont couverts par une documentation séparée.

Détails

Description originale de l’auteur

Guide for implementing Shell-based navigation in .NET MAUI apps. Covers AppShell setup, visual hierarchy (FlyoutItem, TabBar, Tab, ShellContent), URI-based navigation with GoToAsync, route registration, query parameters, back navigation, flyout and tab configuration, navigation events, and navigation guards. Use when: setting up Shell navigation, adding tabs or flyout menus, navigating between pages with GoToAsync, passing parameters between pages, registering routes, customizing back button behavior, or guarding navigation with confirmation dialogs. Do not use for: deep linking from external

repo: dotnet/skills

Popularité

Étoiles GitHub
5.8k
Position au classement
#14588
Licence
MIT
Mis à jour
02/11/2026

Ce skill vous est-il utile ?

0

Connectez-vous pour voter.

Commentaires

  • …

Autres skills de ce dépôt

Skills similaires