| MAUI-index | XAML-in-MAUI | |
.NET MAUI Solution Layout |
MAUI uses a single-project structure that multi-targets platforms while sharing most of your app code and assets. Below is a practical map of what lives where, why it matters, and how it all fits together.
The typical MAUI solution has one .sln (solution) and one primary project (.csproj) that targets Android, iOS, Mac Catalyst, and Windows. Platform-specific files live under a unified Platforms/ folder, while shared UI and assets sit at the root.
ββ π MyMauiApp.sln ββ π MyMauiApp/ β single project (multi-target) ββ π MyMauiApp.csproj ββ π MauiProgram.cs β DI + app builder ββ π App.xaml / App.xaml.cs β app shell & resources ββ π Views/ β pages & screens (XAML/CS) ββ π ViewModels/ β MVVM view models ββ π Models/ β domain/data models ββ π Services/ β data/services/APIs ββ π Controls/ β custom controls ββ π Helpers/ β utilities/extensions ββ π Resources/ β shared assets (fonts, images, styles) ββ π Platforms/ β per-platform code & manifests ββ π Themes/ β color styles, dictionaries ββ π Tests/ β unit/UI tests (optional) ββ π README.md / .editorconfig / .gitignore (optional)
AppShell.xaml for navigation structure (tabs, flyouts, routes).// MauiProgram.cs (core setup)
using Microsoft.Maui;
using Microsoft.Maui.Controls.Hosting;
using Microsoft.Maui.Hosting;
namespace MyMauiApp;
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.ConfigureFonts(fonts =>
{
fonts.AddFont("Inter-Regular.ttf", "InterRegular");
fonts.AddFont("Inter-SemiBold.ttf", "InterSemiBold");
});
// Dependency injection
builder.Services.AddSingleton<MainPage>();
builder.Services.AddSingleton<MainViewModel>();
builder.Services.AddTransient<IDataService, DataService>();
return builder.Build();
}
}
Resources/Images. MAUI auto-generates platform variants (scales/densities) at build.Resources/Fonts and register in MauiProgram.cs. Use the alias in XAML/C#.Resources/Styles or Themes/ for colors, typography, and control styles.Resources/AppIcon and Resources/Splash with a single source image; MAUI generates platform-specific outputs.Resources/Raw accessed via FileSystem.OpenAppPackageFileAsync.MainPage.xaml and code-behind, plus custom controls in Controls/.INavigation.Platform-specific code and manifests live here. Use conditional compilation and partial classes to wire platform features while keeping the shared code clean.
AndroidManifest.xml, MainActivity.cs, MainApplication.cs, platform services (e.g., notifications, permissions), and resource overrides.Info.plist, AppDelegate.cs, SceneDelegate.cs, entitlements, and iOS-specific implementations.Info.plist, AppDelegate.cs, Catalyst-specific configurations (menu items, window behaviors).Package.appxmanifest, App.xaml.cs partials, WinUI host, toast notifications, and windowing APIs.// Example: conditional platform code #if ANDROID // Android-specific implementation #elif IOS // iOS-specific implementation #elif WINDOWS // Windows-specific implementation #endif
Your project file defines targets, assets, and MAUI build behaviors. MAUIβs single project uses multi-targeting to build per-platform binaries.
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFrameworks>net8.0-android;net8.0-ios;net8.0-maccatalyst;net8.0-windows10.0.19041.0</TargetFrameworks> <OutputType>Exe</OutputType> <UseMaui>true</UseMaui> <SingleProject>true</SingleProject> <ApplicationTitle>MyMauiApp</ApplicationTitle> <Version>1.0.0</Version> </PropertyGroup> <ItemGroup> <MauiImage Include="Resources/Images/.png" /> <MauiSplashScreen Include="Resources/Splash/splash.svg" Color="#ffffff" /> <MauiIcon Include="Resources/AppIcon/appicon.svg" /> <MauiFont Include="Resources/Fonts/.ttf" /> <None Include="Resources/Raw/**" Pack="true" /> </ItemGroup> <ItemGroup> <PackageReference Include="CommunityToolkit.Maui" Version="x.y.z" /> </ItemGroup> </Project>
AppShell.xaml and navigate via Shell.Current.GoToAsync("route").OnStart, OnSleep, OnResume-like behaviors via Application events and platform-specific callbacks.MauiProgram.cs and resolve via constructor injection.
// Register routes (AppShell.xaml.cs)
Routing.RegisterRoute("details", typeof(DetailsPage));
// Navigate
await Shell.Current.GoToAsync("details");
Views/, ViewModels/, Services/ by feature (e.g., Features/Orders/...) for scale.#if guards.OnAppearing, and cache images/fonts.MauiProgram.cs sets fonts, handlers, DI.Resources/.Platforms/. | MAUI-index | XAML-in-MAUI | |