Taming the Microsoft .NET MAUI Beast for Multiplatform App Development

Published by D Girma on

Introduction

This article aims to be accessible to a non-technical audience, so a modest effort is made to lay the foundation for understanding important concepts and terms. With regard to .NET MAUI, let’s start by clarifying the .NET technology and the acronym MAUI.

Developed by Microsoft, .NET [1] is a free, open-source, cross-platform framework and provides a programming model, a comprehensive library, and runtime for building Windows, Web, Cloud, Mobile, Gaming, and IoT (Internet of Things) applications. The introduction of .NET 5 and .NET 6 from November 2020 marked a significant shift, unifying the previously separate .NET Core and .NET Framework into a single platform.

.NET MAUI [2], has its root in the Xamarin platform [3]. Xamarin, as a company was founded in 2011, and later acquired by Microsoft in 2016. As a design platform, Xamarin gained popularity for allowing developers to write code in the C# .NET programming language and share a substantial portion of it across Android, iOS, and Windows platforms. Today, Xamarin and .NET MAUI are therefore part of the evolution of cross-platform mobile app development within the .NET ecosystem, with .NET MAUI set to replace or already replacing Xamarin.

Overview of the Challenges

At the heart of .NET MAUI lies the ambitious goal of unifying diverse native user interfaces under one umbrella. This inherent complexity stems from the need to seamlessly integrate Android, iOS, macOS, and Windows UI (WinUI) elements. That is, unifying the native user interfaces (specific to Android, iOS, macOS, WinUI) indeed presents immense challenges in the design, tooling, performance optimizations, and so on.

Two years into this journey, it’s clear that this is no small feat, and the initial learning curve can be steep. In retrospect, embarking on the journey of programming multiplatform apps with .NET MAUI is akin to taming a complex beast, hence the article title.

Two years ago, I embraced the challenge, and after overcoming numerous hurdles and implementing creative workarounds, I can finally say I’ve crafted a satisfactorily working app that paves the way for any future designs. In this article, I will highlight the challenges encountered and the overall experience of navigating the intricate landscape of the .NET MAUI framework.

Platform Discrepancies

Each platform has its own set of guidelines, design principles, and UI components both in hardware and software. Bridging the gap between them requires careful consideration and often necessitates platform-specific code. This, in fact, is the core mission of the Microsoft .NET MAUI project!

To appreciate this, it would help to ponder, what if in the early 1980s both IBM PC (with Intel 8088 CPU) and Apple Macintosh (with Motorola 68000 CPU) adapted the same processor and Operating System (OS). Oh!, I can also hear those dissenting voices arguing that such standardization could stifle innovation. After all, personal computing technologies have historically taken diverse paths.

The landscape of technological divergence was poised for remarkable growth, fundamentally shaping our present world. Notably, the advent of smartphone technologies, led by the Apple iPhone in 2007 and Google Android in 2008, played a pivotal role in this transformative evolution. Microsoft entered the market later, making its presence known in 2010 and intensifying efforts in 2015 with mobile devices running Windows 10 OS. However, as a latecomer, Microsoft struggled to maintain competitiveness in the smartphone market, ultimately announcing the cessation of active development and support for Windows 10 Mobile in 2017. On a personal note, I still miss my Microsoft Lumia 950 XL smartphone [4], that I dare label “the world’s best smartphone that never gained its due acclaim”.

From the user’s perspective, there is no doubt that the smartphone has become an essential tool that we cannot do without today, and it is poised to remain a crucial device in the future. The continuous growth of app stores further enhances the functionality of this indispensable gadget.

Think of the software developers, too. Wouldn’t it be great to write code once and run on all smartphones, and desktops, too?

In the realm of software development, one can envisage the potential of writing code just once and effortlessly executing it across various smartphones and desktop devices. This is the core concept behind the NET MAUI vision.

.NET MAUI is currently addressing the intricate challenges arising from the divergent paths established in the early 1980s with personal computing, and the subsequent emergence of smartphones in the 2000s. These technologies, operating on various CPUs, OSs, and associated APIs (Application Programming Interfaces), have created a complex landscape. Acknowledging this historical context helps underscore the formidable challenges being tackled by .NET MAUI.

Tooling and Documentation

As with any evolving framework, .NET MAUI has undergone changes over the past two years. Navigating through evolving documentation and adapting to updates in tooling has been a consistent challenge. Especially, the ever-evolving landscape of .NET versions has been a formidable challenge.

The .NET MAUI journey began with version 6.0, and over the course of two years, the framework has witnessed significant updates with each subsequent release. The dynamic nature of successive .NET versions introduced a level of instability into the development process. Features that were stable in one version might undergo changes in the next, requiring constant vigilance and adaptation. Navigating the transition from one version to another introduced challenges, as APIs evolved, and new features were introduced. At times, going back to the preceding version was necessary due to regressive as well as new bugs being introduced into new version.

Keeping pace with changes in development environments, SDKs (software development kits), and toolsets added another layer of complexity to the development process. With the framework’s evolution from .NET 5.0 to the present .NET 8.0, the journey has been marked by continual adaptation and refinement.

On the tooling side, the version updates of Visual Studio 2022 (for production release .NET) [5] and Visual Studio 2022 Preview (for .NET under-development)—as the preferred Integrated Design Environment (IDE)—also played a crucial role in shaping the development landscape for .NET MAUI, just as the .NET framework updates do. While each version of Visual Studio brings improvements to the development environment, these enhancements contribute to a more efficient development experience and performance gains but, unfortunately, not without issues which may be regressive or entirely new issues. On one occasion, I had to give up on Visual Studio 2022 Preview for several months because a trivial bug [6] broke the usability of the IDE. As a preview (not a production release) this IDE didn’t get a priority fix – it took over four months to fix [7] what appeared to be a trivial problem.

For me, it was only over the recent six weeks or so that a reasonable design stability versus performance gain were satisfactorily achieved with .NET 8.0. This has enabled me to share my experiences through this article.

Performance Optimization

Achieving optimal performance in any software development involves implementing various strategies and best practices. Designing with .NET MAUI and achieving optimal performance across multiple platforms demands even more—a deep understanding of the complex underlying technologies encompassing different platforms.

Balancing performance without compromising on user experience is a delicate balance. Achieving optimal performance with .NET MAUI involves implementing various strategies and best practices.

 

A Real .NET MAUI Design

Embarking on the intricate journey of designing with .NET MAUI, I have opted to showcase the process through an app seamlessly blending database functionality and multiple API integrations. Drawing from my extensive experience as a productivity tools enthusiast (often as an early adapter) since the early 2000s, I’ve identified a longstanding gap in the Personal Information Management (PIM) landscape. My quest for productivity tools began in the early 2000s with devices like the Compaq/HP iPAQ PDA [8], and software solutions such as PhatNotes and SPB Wallet Information Manager. Despite my continuous exploration of these tools, none seemed to fully meet my comprehensive PIM needs.

Seizing this chance, I introduce a business and personal information management app I call “My Data Wallet” [9]not only as a testament to .NET MAUI’s capabilities but also as a tailored solution to fulfil my PIM needs.

This app project diverges from the conventional enterprise design model, where collaborative efforts between designers and developers are the norm for crafting a seamless and efficient user experience. The uniqueness of this endeavour lies in its distinctive nature, gravitating more towards a proof-of-concept exploration within the realm of a new framework. Given the project’s singular characteristics, I assumed a dual role, spearheading both the design and developer tasks with the assistance of junior associates taking on supportive roles under my guidance.

Overview of the App Features

The detailed features of “My Data Wallet” or MDW app are outlined extensively on the Google Play Store. However, for the purpose of emphasizing the comprehensive design that seamlessly integrates various APIs, and to provide insight into noteworthy challenges, inventive workarounds, and overall hurdles encountered in the .NET MAUI design workflow, here is a condensed summary.

App Features: you can consider each feature as an app in its own right

  • Generic or custom Lists — unlimited in the number list that can created for business, household, or personal info management. The followings add more specialized lists to aid with the app intelligence in what to do with list items.
  • To-do List—with reminders;
  • Birthdays and anniversaries List—any anniversary including such as insurance/subscription renewals with reminders;
  • Budget Lists—with conditional total-sum calculator and PDF printing;
  • Expenses Lists—with conditional total-sum calculator and PDF printing;
  • Flashcards Lists—for self study with built-in flashcard editor;
  • Locations List—for saving places to remember and linked to mapping and many more assistance;
  • Media Link Collection List—captures those important YouTube, TikTok, etc, links for watching later or research-keeping, as well as for shopping links like Amazon;
  • Notes jotter—with customizable font sizes and background colours;
  • Timetable creation—for study or work;
  • And more specialized Lists such as for Software Product Key, MAC (media access control (if you still use Wake-On-LAN for network computers).

 

MDW wallets page

 

User Experience Features: these make the app more efficient, intuitive, user-friendly, and enhance its overall usability.

  • Extensive context menus to manage info items with more intelligence such as for sharing (using external messaging app targets such as WhatsApp);
  • Backup to and restore from cloud storage connected to your device (built around APIs such asOAuth,MSALandMicrosoft Graph);
  • Reminders of all list items of type date/time;
  • PDF printing of Budget Lists and Expenses Lists;
  • Sync with desktop (when Windows version released soon);
  • Upgrade option for encryption of your data at rest;
  • Self contained built-in Help and Tips (context based and on start-up)
  • And many more.

 

MDW wallets page

 

Main Design Components:.NET MAUI components used to build

  • AppShell[10]—Flyout for auxiliary app commands andTabBarfor main app commands;
  • CollectionView—invariably used for item list implementation and represents the core component of the overall design, also used in Grouped Listing mode;
  • SwipeView—for context menu implementation embedded with inner CollectionView data templates;
  • ScrollViewand RefreshView controls—essential for large list items implementation;
  • Entry(for single line)and Editor (for multi-line) controls;
  • SearchHandler—for searching user data items within the PIM database;
  • DatePicker—for date/time data items;
  • Picker—general purpose item picker;
  • WebView—for built-in Help implementation;
  • Numerous Layout controls—withGridcontrol favoured as per .NET MAUI recommendation;
  • Custom controls—for controls tailored for specific tasks such as user password inputting if data encryption is used; customAppShellheader/footer, etc;
  • Numerous other controls—such asRadioButton,ImageButton,CheckBox,ProgressControl,FontAwesomeIcons, and so on.

The preceding summaries offer insights into the intricate and expansive workflows involved in the design and development process. The app features serve as a testament to the app’s versatility, catering to a wide range of PIM tasks. With current production release, the app size is circa 60 MB, a notable achievement considering it was developed with net8.0 and significantly reduced from over 100 MB with previous .NET versions.

While the current app demonstrates efficiency, there exists ample opportunity for further optimization in both app size and performance. MDW app stands as an ongoing project poised for continuous improvement.

Having established the real design scenario in above, let’s now move on to providing a brief overview of the real challenges and the inventive workarounds. It’s important to note that a comprehensive exploration of these challenges would extend into lengthy articles, much like the one you are currently reading.

 

Overview of Challenges and Workarounds

Before discussing an overview of challenges and the creative solutions devised to address them, it’s heartening to note that the .NET MAUI design and development process is not a solitary endeavour. The active engagement of the developer community plays a crucial role in alleviating these challenges, fostering a collaborative and supportive environment.

The.NET MAUI Community Toolkit[11] serves as the mother of all collective packages. It is widely used for utilities such as animations, sharing utilities, playing a pivotal role in substantially easing the design process with well-targeted solutions. Additionally, specialized NuGet packages contributed by individual developers are utilized and duly acknowledged and contribute to the overall richness of the development ecosystem.

Overview of Challenges

As mentioned earlier, overseeing both design and development tasks appear to be a reflection of the 80/20 rule of thePareto principle[12], particularly in terms of time allocation between UI design and business logic-oriented programming. In the context of theModel-View-ViewModel (MVVM)[13] design pattern, a substantial proportion of effort is dedicated to the “View” component, responsible for the User Interface (UI)—essentially, what the user observes on the screen. This is unsurprising, given that, as emphasized in preceding sections, the challenges of multiplatform development stem from the inherent differences among native platforms.

Cataloguing the exhaustive array of issues encountered in this project becomes a daunting task unless one is discerning with the choice of representative issues. The comprehensive documentation on GitHub underscores the sheer volume and dynamic nature of the issues. Presently, there are nearly 3000 open or active.NET MAUI issues[14], while over the project’s lifetime, more than 7400 issues have been successfully resolved or completed. In light of these extensive numbers, with regard to this project, I will provide a succinct summary highlighting selected issues of notable significance.

AppShell Issues:

TheAppShellserves as the primary container for the application’s user interface, establishing the overall structure and navigation flow. While conceptually elegant, its practical implementation encounters several challenges, with varying degrees of complexity across different platforms. A notable feature in Xamarin, theTabbedPage, currently faces compatibility issues with .NET MAUI. However, it’s important to note that this situation may evolve in the future, with anticipated changes or updates potentially resolving the current incompatibility.

  • The execution ofTabBarcommands falls short of expectations, and a noticeable delay during navigation to a different page contributes to an unsatisfactory user experience.
  • With Android, I faced relatively fewer challenges withAppShell. AddressingTabBarissues required the implementation of aShellItemRenderer-based workaround, which proved effective for the Android platform. Unfortunately, these same solutions are not applicable to iOS or WinUI, presenting platform-specific nuances that require distinct approaches.
  • Addressing navigation delays proved to be a more intricate task, primarily involving the emulation of page navigation through the manipulation of content visibility using a layout container, typically aStackLayout.
  • Several challenges arose when working with toolbar icons, where, unexpectedly, icons from one page appeared on a navigated-to page. Some of these issues were rooted in binding not functioning as anticipated, necessitating the development of alternative approaches to address the unexpected behaviour.

It’s worth noting that these workarounds, including various others applied elsewhere, may become obsolete as the identified issues are resolved in future updates.

CollectionView Issues:

TheCollectionViewlist control is a powerful tool for versatile list implementation of the MDW app, demonstrating seamless functionality with Android with the latest update. However, its performance is not as flawless when dealing with iOS and WinUI, presenting challenges that need attention and resolution on those platforms.

  • The integration ofCollectionViewandSwipeViewis ideal for implementing a swipe-based context menu, a necessity for interacting with list items. However, the use ofSwipeViewhas not been resolved for iOS and WinUI.
  • As a workaround specifically for WinUI, a context menu constructed with aTapGestureRecognizerserved as an alternative, effectively simulating the Tap-and-Hold touch gesture for the desired functionality.

Layout Issues:

Dealing with layout issues, including positioning and filling container controls, has been a consistent challenge, necessitating adjustments that used to work seamlessly in Xamarin.

  • In addressing layout issues,Behaviors[15] prove to be invaluable, effortlessly enhancing the functionality of UI controls.
  • For instance, when it comes to layout adjustments, orAttached Behaviors[14] are configured to detect events such as page loading or page-size changes. This triggers code execution, facilitating efficient and precise adjustments to the layout.

Handlers could be the game changer!

While dealing with challenges and workarounds, it’s essential to be up to date with emerging strategies in development with the potential to significantly reduce these obstacles. A particularly exciting design methodology gaining momentum is the use of Handlers[16].

  • By efficiently managing and routing events, this methodology can enhance the responsiveness and flexibility of applications, contributing to a more streamlined and dynamic development process.
  • Keeping a close eye on the evolution of Handlers could offer valuable insights and opportunities for optimizing the design and performance of applications.
  • Beyond tackling UI issues, Handlers play a crucial role in achieving a closer alignment with the native platform’s look and feel.
  • A select number of Handler Mappings have been implemented for controls likeEntry,Editor,CollectionView,DatePicker, andPickerwithin this project. This judicious selection has provided a practical understanding of the advantages offered by this methodology.
  • Notably, the application of Handler Mapping has enabled the configuration of caching parameters for theCollectionViewcontrol, exemplifying the potent capabilities that Handlers bring to design optimization.

The .NET MAUI Design Odyssey

Surveying global sentiments, it becomes evident that the collective journey of the developer community in relation to .NET MAUI is akin to navigating through turbulent waters. Indeed, embarking on the ambitious journey of .NET MAUI proves to be a formidable challenge, invoking a wave of frustration within the developer community.

Opinions echoing this discontent bear titles ranging from sceptical inquiries like “Is MAUI dead on arrival?” to more critical assessments such as “Is MAUI mature enough for enterprise-grade native application deployment?” Some even go so far as to dub MAUI as nothing more than a “SCAM.” While these extreme claims may be unwarranted and lack justification, they serve as an exaggerated reflection of the genuine frustrations prevailing in the developer landscape. This discontent, albeit intense at times, serves as a meaningful barometer gauging the true challenges faced by .NET MAUI.

 

Conclusions

Taming .NET MAUI is undeniably a formidable challenge, but the journey is marked by valuable learning experiences and rewards. As the framework continues to evolve, the development community will play a crucial role in shaping its future. Navigating through the complexities, embracing creativity in problem-solving, and actively participating in the community are the keys to unlocking the full potential of .NET MAUI for multiplatform app development. Notable community engagements include the.NET MAUI’s GitHub project site[17] for raising, tracking, and discussing issues; the.NET MAUI Community Toolkit’s GitHub project site[18]; and theMicrosoft Learn site[19], for asking and answering questions on anything Microsoft, including .NET MAUI.

Navigating the evolution of .NET MAUI from version 6.0 to the recent stability of .NET 8.0 has been a journey marked by resilience and adaptability. The challenges posed by version transitions have been met with determination, community collaboration, and a commitment to staying abreast of the evolving landscape. As stability becomes a constant, the .NET MAUI development community can now focus on leveraging the full potential of the framework to create robust, multiplatform applications.

Visual Studio 2022 and its Preview version (supporting the latest .NET in development phase, currently net8.0) are integral components of the .NET MAUI development ecosystem. The updates they bring, including tooling enhancements, template improvements, compatibility, and bug fixes, significantly impact the overall experience of building cross-platform applications with .NET MAUI. Developers are encouraged to stay abreast of the latest Visual Studio updates to take full advantage of the evolving capabilities in both the IDE and the .NET MAUI framework.

.NET MAUI simplifies multiplatform integration, offering a solution to complex challenges. Mastering design and development strategies leads to the clear benefit of writing code once and targeting multiple platforms, expanding app reach across diverse markets. Currently, the Android platform is released, and the Windows version is in the Alpha stage, with minor issues likeSwipeViewandAppShell TabBaron Android requiring creative workarounds. The parallel design of WinUI streamlines development, leveraging its native desktop convenience for prototyping in XAML withHotReload, minimizing reliance on Android emulators. iOS implementation is progressing, with focused attention on completion.

Finally…

A credit where it’s due for this amazing technology: a heartfelt expression of gratitude is extended to the Xamarin team for their visionary approach, in uniting developers within a collaborative framework rather than the segmented coding landscape that would otherwise be the case. Special appreciation is also extended to Microsoft for transforming the ambitious .NET MAUI project from concept to reality on a grand scale. The collective efforts of both teams have not only bridged gaps in development but have also significantly shaped and realized the expansive potential of the .NET MAUI framework.

Finally, finally…

I wanted to take a moment to address the challenges we’ve encountered in our project timeline due to complexities associated with .NET MAUI. The intricacies of the framework have led to unforeseen delays, and my company and I sincerely apologize for any inconvenience this may have caused to our investors. In particular, I would like to extend my gratitude to BA for the invaluable assistance provided during the project, especially in facilitating the acquisition of high-powered computing resources that .NET MAUI design environment demands. Your unwavering support and patience have been instrumental in overcoming obstacles, and I genuinely appreciate your commitment to our collective success.

To AI, DR, FB, GF, HA, NG, ST, and TM, I want to express my sincere thanks for your understanding and patience throughout this process. Your continued support has been crucial, and I am confident that the benefits we are poised to reap from the implementation of .NET MAUI will make the wait worthwhile. Thank you for your ongoing commitment to our shared goals. I am optimistic about the positive outcomes ahead, and I appreciate your continued trust in our endeavours.

Postscript: A free version of MDW app is available for Ethiopia here at Google Play store[20].

References

  1. “What is .NET?”,https://dotnet.microsoft.com/en-us/learn/dotnet/what-is-dotnet
  2. “What is .NET MAUI?”,https://learn.microsoft.com/en-us/dotnet/maui/what-is-maui?view=net-maui-8.0
  3. “What is Xamarin?”,https://learn.microsoft.com/en-us/xamarin/get-started/what-is-xamarin
  4. “Microsoft Lumia 950 XL”,https://en.wikipedia.org/wiki/Microsoft_Lumia_950_XL
  5. “Visual Studio 2022”,https://visualstudio.microsoft.com
  6. “I cannot get to the Project Properties Editor for MAUI project. How to fix this?”,https://learn.microsoft.com/en-us/answers/questions/1221343/i-cannot-get-to-the-project-properties-editor-for
  7. “Csproj Editor does not open due to AndroidPackageFormat”,https://developercommunity.visualstudio.com/t/Csproj-Editor-does-not-open-due-to-Andro/10333050
  8. “iPAQ”,https://en.wikipedia.org/wiki/IPAQ
  9. “My Data Wallet” app at Google Play Store,https://play.google.com/store/apps/details?id=com.oromiasoft.mdw
  10. “Create a .NET MAUI Shell app”,https://learn.microsoft.com/en-us/dotnet/maui/fundamentals/shell/create?view=net-maui-8.0
  11. “.NET MAUI Community Toolkit”,https://github.com/CommunityToolkit/Maui
  12. “Pareto principle”,https://en.wikipedia.org/wiki/Pareto_principle
  13. “Model-View-ViewModel (MVVM)”,https://learn.microsoft.com/en-us/dotnet/architecture/maui/mvvm
  14. “.NET MAUI Issues”,https://github.com/dotnet/maui/issues
  15. “Behaviors”,https://learn.microsoft.com/en-us/dotnet/maui/fundamentals/behaviors?view=net-maui-8.0
  16. “Handlers”,https://learn.microsoft.com/en-us/dotnet/maui/user-interface/handlers/?view=net-maui-8.0
  17. “dotnet/maui project site”,https://github.com/dotnet/maui
  18. “.NET MAUI Community Toolkit”,https://github.com/CommunityToolkit/Maui
  19. Microsoft Learn (a hub for Q&A and more)”,https://learn.microsoft.com
  20. My Data Wallet app at Google Play Store”, https://play.google.com/store/apps/details?id=com.oromiasoft.miw

0 Comments

Leave a comment:

Avatar placeholder