liveBook · Manning

Desktop application layout

As explained in .NET MAUI in Action

A desktop application layout is an interface arrangement optimized for large screens, pointer input, and desktop interaction conventions.

A desktop-specific layout gives a .NET MAUI app a professional desktop UX instead of feeling like a mobile app lifted onto a larger screen. Menus and windows extend that layout with familiar desktop interaction patterns. section 10.3.3

Build the desktop experience around two platform conventions:

  • Add page menus through MenuBarItems, MenuBarItem, and MenuFlyoutItem; trigger behavior with a Clicked event or bound command. section 10.3.3
  • Create additional windows by assigning a ContentPage to Window, setting properties such as Title, Width, and Height, and calling OpenWindow. section 10.3.3
  • Keep desktop-only menus out of mobile layouts without using OnIdiom, because the menu bar appears only on desktop. section 10.3.3

Report page with an About window

Add a Help menu containing an About command to ReportPage. Bind the command to ShowAboutPage, create an AboutPage inside a new Window, size it to 300 by 300, and open it with Application.Current.OpenWindow. section 10.3.3

Listing 10.20 The ReportPage.xaml menu
<ContentPage.MenuBarItems>                  #1
    <MenuBarItem Text="Help">               #2
        <MenuFlyoutItem Text="About"        #3
 
                        Command="{Binding
 ShowAboutPageCommand}"/>                 #4
    </MenuBarItem>
</ContentPage.MenuBarItems>

Use the menu listing as a compact template for a desktop Help menu and its bound About action. section 10.3.3

Listing 10.21 The ShowAboutPage method in ReportViewModel
public void ShowAboutPage()
{
    var newWindow = new Window(new AboutPage())
    {
        Title = "About",
        Width = 300,
        Height = 300
    };
    Application.Current.OpenWindow(newWindow);
}

Use the window listing as a practical pattern for constructing, sizing, and displaying a secondary desktop window. section 10.3.3

How .NET MAUI in Action covers it

How deep it goes
Explains menu APIs, commands, window construction, sizing, and opening, with additional iOS multiwindow configuration shown.
Examples
Uses a ReportPage Help menu, an About command, an AboutPage, and a separately sized About window.
What it assumes
Assumes a .NET MAUI page and binding structure while teaching desktop menus and additional windows directly.
What you can do after
Build desktop menus and secondary windows in a .NET MAUI application.
How it connects
Connects desktop layouts with .NET MAUI pages, menus, commands, windows, data binding, and platform scene configuration.

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.