liveBook · Manning

MauiApp

As explained in .NET MAUI in Action

MauiApp is the .NET MAUI application object produced by application startup configuration.

MauiApp is the application object returned by CreateMauiApp in MauiProgram.cs. The method builds it through the .NET generic host pattern, and the resulting object starts the .NET MAUI application. section 2.3

Creating the application

A typical startup method creates a builder, applies UseMauiApp<App>(), configures fonts, and returns builder.Build() as a MauiApp. The App object then assigns a Page to its MainPage member for display. section 2.3

Listing 2.1 MauiProgram.cs
namespace AlohaWorld;
 
public static class MauiProgram
{
    public static MauiApp CreateMauiApp()         #1
 {
        var builder = MauiApp.CreateBuilder();    #2
     builder
            .UseMauiApp<App>()                    #3
            .ConfigureFonts(fonts =>
            {
                fonts.AddFont("OpenSans-Regular.ttf",  "OpenSansRegular");
                fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
            });
        return builder.Build();                   #4
    }
}

Inspect the complete MauiProgram.cs startup flow, including builder creation, application registration, font configuration, and construction of the MauiApp object. section 2.3

How .NET MAUI in Action covers it

How deep it goes
Explains the builder flow, application registration, and displayed page, but stops short of deeper page and view behavior.
Examples
Uses MauiProgram.cs with builder.Build(), UseMauiApp<App>(), font registration, and App.xaml.cs assigning new MainPage().
What it assumes
Builds from familiarity with a C# Main method while introducing the .NET MAUI startup and page-display flow.
What you can do after
Operate/configure a .NET MAUI startup method that builds MauiApp and launches an App displaying its initial Page.
How it connects
Connects CreateMauiApp, MauiProgram, generic host builder, UseMauiApp, App, Application, IApplication, Page, and MainPage.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of .NET MAUI in Action. The section links point to the parts of the book it draws on.