Article
14 Dec
2023

.NET MAUI: Redefining Cross-Platform App Development

.NET MAUI is revolutionising cross-platform application development as part of the larger .NET 8 ecosystem, allowing developers to build stunning apps in less time using one single codebase. Discover the transformative capabilities firsthand.
Ivo Rodrigues
|
8
min read
net-maui-redefining-cross-platform-app-development

Microsoft has released an updated version of .NET MAUI (Multi-platform App UI). Also called “dotnet/MAUI,” “MAUI net,” or “MAUI dotnet.” Previously released in 2022 with .NET6, NET MAUI is revolutionising cross-platform application development as part of the larger .NET 8 - learn more about .NET 8 here - ecosystem, allowing developers to build stunning apps in less time using one single codebase. 

In the not-so-distant past, cross-platform app development inevitably meant dealing with multiple technologies and frameworks to create apps that could work on various platforms seamlessly. This resulted in several issues, including code duplication, reduced developer productivity, and increased code complexity—not to mention the costs involved.

With the .NET MAUI framework, developers now have access to a unified framework to write application logic one time and have it deployed across the web, Windows, iOS, Android, and MacOS. .NET MAUI is changing the way developers create desktop, mobile, and web applications. This blog is a comprehensive overview of what .NET MAUI is, how it works, and how it fits into the broader .NET framework. Let’s begin.

What Is .NET MAUI?


.NET MAUI is the newest iteration of the open-source framework Xamarin.Forms, which was also widely used for cross-platform app development. .NET MAUI builds on Xamarin’s strengths while adding new, more useful features relevant to modern cross-platform app development. The result is an improved and updated platform with better performance and expanded capabilities.

.NET MAUI can create native desktop and mobile applications with XAML and C#. Like Xamarin, it is also open-source, with MAUI UI controls improved to provide better performance and scalability. 

While MAUI development is praised for its cross-platform capabilities, it’s important to note that you can still add platform-specific code and resources as needed. With .NET MAUI, you can create applications for iOS, Android, macOS, and Windows. Whether you choose to do so from a single codebase or by creating specific code per platform is up to you.

Source: Microsoft

However, the key goal of the MAUI UI framework is, of course, to enable developers to implement the majority of their UI layout and app logic from one single codebase. In a nutshell, therefore, with .NET MAUI, you can:

  • Write MAUI C# or XAML cross-platform apps from a unified codebase via Visual Studio
  • Share code, app and business logic, and user acceptance tests across platforms
  • Share app UI design and layout across platforms
Source: Microsoft

.NET MAUI in .NET 8

With the much-anticipated release of .NET 8, .NET MAUI is a powerful addition, especially for those looking to leverage the .NET framework’s cross-platform capabilities. .NET MAUI in .NET 8 enhances the framework’s overall performance, stability, and developer experience through performance improvements and platform-specific fixes.

Quality and Performance Improvements

.NET MAUI boasts an increased battery of manual and automated testing, as well as a narrowed focus on regressions. Performance enhancements have also been made to “Setter Specificity” performance and ActivityExtensions.GetWindowFrame on Android to improve overall app performance. 

Additionally, performance optimisations such as improved rendering speed, faster startup times, and an overall smoother user experience have also been made in .NET MAUI. 

Fixes on Controls and UI Elements

To improve end-user app UI and make them more visually consistent and accurate, updates and fixes were also made on several UI elements and controls, such as:

  • Android text alignment
  • CollectionView
  • TabBar visibility
  • RoundRectangle Borders

Platform Fixes

Improvements have also been made to the MAUI platform to ensure a better and more consistent developer experience. These include the drag-and-drop functionality, the appearance of the tab bar, and several platform behaviours for a more streamlined workflow. 

Addresses Stability Issues

Microsoft has also improved .NET MAUI’s reliability and stability based on reported stability issues with Xamarin.Forms, so the new UI is more reliable and stable, ideal for handling cross-platform development requirements. 

Better Accessibility

.NET MAUI’s framework is equipped with more accessibility features that allow developers to create more inclusive applications that can cater to users with special accessibility needs.

Better Tooling and Developer Experience

.NET MAUI also comes with improved tooling support for better productivity and more streamlined workflows. These include more intuitive debugging capabilities, smoother development tooling integration, and improved IntelliSense. 

Comprehensive Documentation and Resources

Microsoft has also extensively documented and compiled guides and learning resources to help developers learn .NET MAUI quickly, including migrating existing projects and files to .NET MAUI, best practices for cross-platform app development, and documentation for onboarding and troubleshooting. 

Advantages of .NET MAUI 

Before .NET MAUI, there was Xamarin.Forms, a User Interface toolkit that allowed for creating UIs for iOS, Windows, and Android using a unified codebase. It already facilitated cross-platform app development through a shared UI abstraction layer. 

Arguably, both Xamarin.Forms and .NET MAUI provide developers with a platform to build cross-platform applications, but .NET MAUI takes Xamarin’s capabilities further with its new key features. .NET MAUI is described as the “evolution” or next step of Xamarin, with extended support for additional platforms and an even more powerful unified development experience.

New MVU Architecture

In terms of architecture, Xamarin.Forms used a page-centric architecture that allowed developers to create pages and then combine these pages to build the UI. Xamarin also relied on platform renderers for rendering the UI components on each platform. 

With .NET MAUI, a new architecture applying the Model-View-Update (MVU) pattern is used, and its goal is to simplify UI development. Through the MVU pattern, developers can define an app’s state and logic using a single code file without needing to create multiple pages that require rendering. This allows for a more reactive and unified UI development approach. 

Expanded Performance Capabilities

Performance-wise, Xamarin allowed for native-level access to application programming interfaces on a platform-specific level. However, the downside is those apps usually experienced slower startup times since they had to initialise the Xamarin.Forms framework each time. 

With .NET MAUI, Microsoft emphasises improving overall performance and startup times via several performance optimizations and significant framework overhead reduction. Ahead-of-time (AOT) and single-project compilation are also new features of .NET MAUI to improve app performance further.

Wider Platform Support

In terms of supported platforms, Xamarin offered support for app creation across iOS, Android and Windows using a single codebase. .NET MAUI further expands this by supporting MacOS and Tizen, allowing for an even more comprehensive cross-platform development experience. 

Larger Ecosystem and More Development Tools

Regarding ecosystem and development tools, Xamarin was already ahead of the game with an established ecosystem and comprehensive development tools. Integrations with development environments like Visual Studio also enhanced the selection of libraries and plugins for developers to access.

.NET MAUI leverages this comprehensive ecosystem and tooling. It further fine-tunes tooling integrations and streamlines the overall development experience. .NET MAUI is also more productivity and collaboration-focused with features like code-sharing across various .NET platforms. 

Xamarin to MAUI Migration and Project Compatibility

Projects currently on Xamarin.Forms can easily be migrated to .NET MAUI thanks to Microsoft’s migration tools. While there will still be a degree of updating involved, such as adapting to new APIs and patterns and updating the codebase — .NET MAUI was generally designed to be backwards-compatible.

This means the two programs will have a smooth upgrade path between them, from Xamarin to MAUI, to encourage developers to leverage new capabilities and enhancements without needing to redo entire projects in .NET MAUI.

Some of the features and controls in .NET MAUI that make it easier and better to upgrade from Xamarin are as follows:

  • Functional controls to display data, indicate activity, initiate actions, display collections, and pick data.
  • A more detailed layout engine for app page design and layout
  • A wider selection of various page types to create rich navigation types 
  • Handler customization for enhanced UI element presentation 
  • Data-binding support to facilitate elegant, sustainable development patterns
  • Cross-platform graphics via a drawing canvas to support the painting and drawing of images, shapes, graphical object transforms, and operations composites

How .NET MAUI Works 


.NET MAUI mobile, web and desktop apps can all be built via a single framework, which generally follows the below architecture:

.NET MAUI architecture diagram.
Source: Microsoft

To develop an app via .NET MAUI, you are primarily writing code that interacts with the main .NET MAUI API. The API then directly consumes the APIs of native platforms:

  • .NET for Android
  • .NET for iOS
  • .NET for MacOS
  • .NET for Windows

Additionally, app code can also directly exercise platform APIs as needed. .NET MAUI applications can be written using Mac or PC and then compiled into native app packages:

  • Android apps compile from C# into intermediate language (IL), then just-in-time (JIT) to native assembly upon app launch. 
  • iOS apps are compiled from C# as well but are fully ahead-of-time (AOT) into native ARM assembly upon app launch.
  • MacOS apps use Mac Catalyst — this is an Apple-specific solution that brings iOS apps built with UIKit to the desktop, augmenting it with supplementary APIs and AppKits as needed.
  • Windows apps use the WinUI3 library to create native apps targeting Windows desktops.

.NET MAUI Single Project

A single project allows for unifying platform-specific development elements into a single shared project targeting various platforms. It uses multi-targeting and SDK-style projects to do so.

.NET MAUI’s single project functionality aims to simplify the cross-platform development process and introduce consistency throughout the whole project, regardless of platform. Among its notable features are:

  • Multi-platform targeting 
  • A single entry point for cross-platform app development
  • Shared resource files within one project
  • Simplified debug target selection for apps
  • Single app manifest indicating app title, ID, and app version
  • Platform-specific APIs and tools can also be accessed 

Cross-platform APIs

.NET MAUI is also equipped with cross-platform APIs to access native device features like accelerometer, GPS, battery levels, and network status. More specifically, with .NET MAUI, functionalities for accessing device features include:

  • Accessing device sensors (gyroscope, accelerometer, compass, etc.)
  • Capability for checking the device’s network connectivity or detecting changes
  • Accessing information about the device the app is running on
  • Copying and pasting text between apps via the system clipboard
  • Storing data securely as key/value pairs
  • Selecting single or multiple files from the device
  • Using the device’s text-to-speech engine to read text
  • Initiating authentication flows via the browser by listening for a specific app-registered URL callback

.NET Hot Reload

.NET MAUI includes support for .NET hot reload, which allows you to modify managed source code and XAML while the app is running and observe modified results without rebuilding from scratch. This is also available for all types of projects on .NET core, not just MAUI.

Usually, source code modification will require manual pausing or hitting a breakpoint. With hot reload, your code edits can be applied to your running app without recompiling.

MAUI also supports XAML hot reload, so you can save XAML files and see changes as the app runs without recompilation. The navigation state, as well as data, will also be maintained, allowing for quick UI iteration without losing your place in the app.

Conclusion 

.NET MAUI’s launch in the .NET framework undoubtedly marks a landmark moment in cross-platform app development. .NET MAUI takes Xamarin.Forms’ strengths and raises the bar even higher by adding more functionalities and features for a truly smooth, more integrated app development experience. 

Its powerful features, like multi-platform targeting, .NET hot reload, and single project, are set to make developing high-quality, sophisticated apps faster and more cost-effective. Tedious tasks, like testing and debugging, have also been thoughtfully optimised with cross-platform development in mind.

Most importantly, Microsoft has gone the extra mile in ensuring that migration from Xamarin to MAUI is a breeze and that newer users can also easily learn the ropes through extensive documentation and learning guides. All these, combined with the new .NET 8 framework’s improvements and LTS launch, signal exciting times for developers looking to develop high-performance and complex applications across various platforms. 

Build Intelligent Platforms With The Virtual Forge

Visit The Virtual Forge website for more content on data, development and technology. We also offer extensive development services, so if you’d like to learn more about building cross-platform apps with .NET MAUI, feel free to get in touch with us.

At The Virtual Forge, we aim to build data-rich, intelligent platforms that solve real-world problems. We use a collaborative approach that lets us know what our clients need so that we can provide efficient and unique solutions for their business problems. 

FAQs

What platform is .NET MAUI built on?

.NET MAUI is built on the same platform as Microsoft XAML. This allows for the development of cross-platform apps via a single codebase.

What can .NET MAUI be used for?

.NET MAUI can be used to develop a wide range of mobile, web, and desktop apps. It allows developers to create apps for several platforms without needing to code separately for each, saving time, money, and resources.

Our Most Recent Blog Posts

Discover our latest thoughts, tendencies, and breakthroughs in the realm of software development and data.

Swipe to View More

Get In Touch

Have a project in mind? No need to be shy, drop us a note and tell us how we can help realise your vision.

Please fill out this field.
Please fill out this field.
Please fill out this field.
Please fill out this field.
Send Message

Thank you.

We've received your message and we'll get back to you as soon as possible.
Sorry, something went wrong while sending the form.
Please try again.