Top 5 new features for developing powerful desktop apps

Top 5 new features for developing powerful desktop apps

Last month, Microsoft published an overview type of .NET Dev blog post that introduces 5 .NET MAUI features for building great desktop applications.

In the original blog post, .NET Community Senior Program Manager James Montemagno highlighted the top five features of .NET MAUI for desktop applications. These include support for multiple windows, a top-level menu bar, context menus, tooltips, and pointer gestures. They can help improve user experience and take advantage of desktop platform hardware and operating systems.

The .NET MAUI framework has undergone a major change in the Window it currently serves as the basis for content display. An Application creates a default window that automatically displays its content at runtime. With the new one CreateWindow method in the Application class, any new window can be created. When running apps 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 ability to open and close the new window using the built-in API:

var weatherDetails = new Window(new WeatherDetailsPage());

// Close a specific window

// Close the active window

Microsoft Learn provides documentation items on .NET MAUI multi-window configuration.

One of the primary functions in desktop applications is the menu bar, which is typically integrated into the application on Windows and into the system menu bar on Mac.

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

See also  Banner Health sleep medicine expert recommends clinical applications for sleep conditions - Greeley Tribune

(Image credit: Microsoft)

All ContentPage contains the MenuBarItems collection that can contain different levels of menus. Menu items can be created directly in XAML or C#, giving menus a dynamic feel. Menu items can be enabled or disabled and include separators, submenus, and icons on Windows. They can also be tied to Command or have one Clicked event. If you want to learn more about the menu bar, we recommend that you 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 applications when you want to provide users with more choices when they right-click an item. The context menu is created with an API similar to the menu bar, but depending on the situation, it is displayed on a specific controller. Just like menu items, context menus can be linked to the event command, and can contain icons, submenus, and dividers.

The following example shows how to use the context menu 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 a control in an application to ToolTipProperties.Text attached property. This can be set in XAML or programmatically for any control.

See also  Biden cuts US credit card and application fees

For desktop users and their external devices, .NET MAUI also features new gesture recognizers specifically for mouse pointers that can detect pointer events during controller interaction and provide the pointer’s position relative to the controller. This allows developers to perform specific actions in response to pointer movement.

You can read more about these and other additional services in Microsoft’s official documentation on .NET MAUI development.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *