| MAUI-FlyoutPage | TabBar-vs-Shell-Tab | |
ContentPage vs Page in .NET MAUI |
In .NET MAUI, the root element of a XAML file should match the type of the page class defined in the code-behind. Most commonly, this is ContentPage, not Page.
✅ Use <ContentPage> as the root element for most screens.
✅ Use <Shell> for Shell-based navigation.
✅ Use <FlyoutPage> or <TabbedPage> for those specific navigation patterns.
❌ Avoid <Page> unless creating a custom page type.
| Feature | ContentPage | Page |
|---|---|---|
| Usage | Most common for screens | Base class, rarely used directly |
| Layout Support | Yes (StackLayout, Grid, etc.) | No |
| Recommended as Root | ✅ Yes | ❌ No |
XAML File
└── Root Element
├── Matches Code-Behind Class Type
├── Defines Layout
└── Contains Controls
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MyApp.MainPage">
<VerticalStackLayout Padding="20">
<Label Text="Welcome to .NET MAUI!" FontSize="24" />
<Button Text="Click Me" Command="{Binding ClickCommand}" />
</VerticalStackLayout>
</ContentPage>
+---------------------+ +-------------------+ +-------------------+
| View | | ViewModel | | Model |
| (XAML + CodeBehind) | ---> | Commands & Data | ---> | Business Logic |
| UI Elements | | Properties | | Data Access |
+---------------------+ +-------------------+ +-------------------+
Flow:
1. XAML binds to ViewModel properties using BindingContext.
2. ViewModel exposes Commands for user actions.
3. ViewModel interacts with Model for data and logic.
4. Updates propagate back to View via data binding.
| MAUI-FlyoutPage | TabBar-vs-Shell-Tab | |