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
