Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News .NET MAUI: Top Five New Features for Powerful Desktop App Development

.NET MAUI: Top Five New Features for Powerful Desktop App Development

Last month Microsoft published the overview type of .NET Dev blog post showing the five .NET MAUI Features for Building Great Desktop Apps.

In the original blog post, James Montemagno, the principal lead program manager, .NET Community, highlighted the top five features of .NET MAUI for desktop apps. These features include multi-window support, a top-level menu bar, context menus, tooltips, and pointer gestures. They can help enhance the user experience and take advantage of the hardware and operating system of desktop platforms.

The .NET MAUI framework has undergone a significant change with the Window now serving as the base foundation for content display. An Application creates a default Window that automatically displays content upon running. With the new CreateWindow method in the Application class, any new Window can be created. When running applications on a desktop or tablet, the larger screen size can be used to display more information by creating additional windows instead of navigating to different pages.

Developers now have the option to open and close the new window with the built-in API:

var weatherDetails = new Window(new WeatherDetailsPage());
// Close a specific window

// Close the active window

Microsoft Learn provides documentation items about the configuration of multi-window in .NET MAUI.

In desktop applications, one of the primary features is the menu bar, which is typically integrated into the application on Windows or in the system menu bar on Mac.

.NET MAUI simplifies the process of integrating a menu bar by requiring just a few lines of code. Additionally, this feature allows users to access the menu on an iPad using a keyboard.


(Image source: Microsoft)

Every ContentPage contains a MenuBarItems collection, which may contain menus at different levels. Menu items can be created directly in XAML or via C#, giving the menus a dynamic feel. The menu items have the ability to be enabled or disabled and contain separators, sub-menus, and icons on Windows. Additionally, they can be bound to a Command or have a Clicked event. To learn more about the menu bar, it is recommended to review the documentation.

<ContentPage ...>
        <MenuBarItem Text="File">
            <MenuFlyoutItem Text="Exit"
                            Command="{Binding ExitCommand}" />
        <MenuBarItem Text="Locations">
            <MenuFlyoutSubItem Text="Change Location">
                <MenuFlyoutItem Text="Redmond, USA"
                                Command="{Binding ChangeLocationCommand}"
                                CommandParameter="Redmond" />
                <MenuFlyoutItem Text="London, UK"
                                Command="{Binding ChangeLocationCommand}"
                                CommandParameter="London" />
                <MenuFlyoutItem Text="Berlin, DE"
                                Command="{Binding ChangeLocationCommand}"
            <MenuFlyoutSeparator />            
            <MenuFlyoutItem Text="Add Location"
                            Command="{Binding AddLocationCommand}" />
            <MenuFlyoutItem Text="Edit Location"
                            Command="{Binding EditLocationCommand}" />
            <MenuFlyoutItem Text="Remove Location"
                            Command="{Binding RemoveLocationCommand}" />                            
        <MenuBarItem Text="View">
            <!--More items-->

Context menus are used in.NET MAUI apps when you want to provide users with more choices when they right-click an element. The context menu is made using a similar API to the menu bar, but it is displayed on a particular control depending on the situation. Similar to the menu items, context menus can also bind to a Command for the event; it can contain icons, sub-menus, and dividers.

The example below demonstrates the usage of the context menu on Editor control.

            <MenuFlyoutItem Text="Bold" Clicked="OnBoldClicked"/>
            <MenuFlyoutItem Text="Italics" Clicked="OnItalicsClicked"/>
            <MenuFlyoutItem Text="Underline" Clicked="OnUnderlineClicked"/>

Tooltips can provide additional context when desktop users hover over control in an application using the ToolTipProperties.Text attached property. This can be set in XAML or programmatically for any control.

Regarding desktop users and their external devices, .NET MAUI also has new gesture recognizers specifically for mouse pointers that can recognize pointer events when interacting with a control, and provide the pointer's position relative to the control. This allows developers to perform specific actions in response to the pointer's movements.

More about these and other additional features can be found by browsing the official documentation provided by Microsoft about .NET MAUI development.

About the Author

Rate this Article