.NET Multi-platform App UI (MAUI) is a development framework for building native mobile and desktop apps with C# and XAML. The framework enables developers to create client applications that deliver rich user interactions, high performance and native platform experiences, all by building on the native UI frameworks of Android, iOS, macOS and Windows.
.NET developers are already .NET MAUI developers, as .NET code uses the same base class library and run time; the platform employs the same build patterns to create the app instance, configure dependencies, access lifecycle events and more. This means the startup and configuration of a .NET MAUI app will look very familiar and developers can hit the ground running. The structure looks a lot like other .NET solutions where the app is a single project and you have direct access to each platform from just one project. However, while code can be shared between web, mobile and desktop, you might want to focus on one particular platform. Fortunately, Microsoft has this covered. If your business wants to build an incredible desktop app, .NET MAUI is the perfect solution.
Why Use .NET MAUI for Desktop Development?
Not only can .NET MAUI be used to build cross-platform mobile apps, it’s also a formidable platform for crafting beautiful desktop apps for Windows and Mac. Better still, you have the choice to just target desktop platforms or enable it to work across mobile too. For desktop platforms, developers get the most modern toolkit with WinUI with Windows App SDK and Mac Catalyst for macO. And, as well as delivering .NET MAUI apps to desktop, Microsoft’s offering for .NET 7 delivers desktop-specific controls for app-level menus, tooltips, context menus and more.
Desktop Specific Controls in .NET MAUI
While code can be shared across platforms, .NET MAUI also delivers when you want to create desktop-native features. In fact, in .NET 7, there are additional controls and features that specifically target desktop. So, instead of just being able to deliver mobile experiences on desktop, you can create rich desktop experiences to meet the needs of your business. Desktop-specific controls can enhance the user experience and as well as speed up the development process. If your development team is using .NET MAUI, the following five features can be extremely valuable:
1. Multi-Window Support
The addition of the Window as the base foundation was a fundamental change for .NET MAUI. When developers create and run a .NET MAUI app, it automatically creates a Window and uses it to display content. However, the application class also has the CreateWindow method that is invoked when a new Window is created. As desktop apps can take advantage of more real estate, creating a second or third window makes it much easier to navigate. Users gain multiple views and aren’t constrained to a single window of information.
2. Top Level Menus
The menu bar is a key feature of desktop applications .NET MAUI enables developers to integrate the menu bar with just a few simple lines of code. Menu items have separators, sub-menus and icons and can be enabled or disabled. With complete menu bar documentation available, it makes including top level menus a breeze.
3. Context Menus
Context menus come into play when developers want to give more options based on specific content. This is achieved using a similar API to the top level menu bar. However, it’s placed on a specific control. As with the menu bar, it’s possible to bind a command with icons, sub-menus dividers and more. From any ContentPage, you can add a hierarchy of menu items and then link them to events or commands.
As desktop users have a mouse and keyboard available to them, it’s helpful to be able to provide additional context when they hover over a control. Tooltips are great for providing simple contextual clues in the UI and are the ideal solution for quickly adding functionality that can enhance the user experience. By using the Tooltips tool in .NET MAUI, you can easily specify additional information to enhance the user experience.
5. Pointer Gestures
Another key way to enhance desktop applications, bearing in mind that they may be navigating using a mouse or keypad, is to be able to recognize gestures with the mouse pointer. .NET MAUI can recognize when any pointer has entered, exited or moved inside a control. By recognizing when a pointer interacts with a control, developers can perform actions accordingly. With PointerGesture, you can add visual animations to enhance this further by changing the colour, underlining, scaling and more.
Developer Tooling for .NET MAUI
Visual Studio on Windows and Mac delivers the most productive developer experience for .NET MAUI. One of the key tools is hot reload, enabling you to make changes, fix bugs, apply them and see them live. Hot reload saves a huge amount of time stopping, rebuilding and deploying just to see the difference that changes will make. Instead, changes are reloaded as soon as they’re valid while preserving the UI and app state. Also, one of the newest tools for developers in Visual Studio is Live Preview. Live Preview offers the ability to see the app right inside the IDE; it’s possible to zoom in on the area being worked on, aligning to pixel level and inspecting the UI to navigate to code. This is another huge time-saving, especially if the code base isn’t immediately familiar. There is also Live Visual Tree, offering a tree view representation of the UI hierarchy.
Writing robust, powerful code that can be easily tested is vital for any development project. If you’re developing for desktop, .NET MAUI supports the Model-VIew-View-Model (MVVM) pattern for separation concerns, data binding, commanding and more. This enables developers to use their own app architecture or use community libraries. With the Microsoft Community Toolkit, there are MVVM libraries, including fantastic source generators that help deliver better, faster code.
Creating Powerful Applications for Your Business
Every year, Microsoft delivers new features for .NET MAUI and a faster, more secure .NET platform. So, whether you’re planning to build a mobile, desktop or cross-platform application, with .NET MAUI developers, you have all the tools at your fingertips to deliver powerful desktop applications for your business.