Reader small image

You're reading from  The MVVM Pattern in .NET MAUI

Product typeBook
Published inNov 2023
Reading LevelBeginner
PublisherPackt
ISBN-139781805125006
Edition1st Edition
Languages
Right arrow
Author (1)
Pieter Nijs
Pieter Nijs
author image
Pieter Nijs

Pieter Nijs is a .NET consultant at Xebia in Belgium, with a keen interest in mobile and cloud development. He's been instrumental in diverse projects, from vast healthcare and telecom systems to compact LOB apps. Now, Pieter's exploring AI's potential to enhance customer projects innovatively. Passionate about technology, he actively experiments and shares knowledge as a conference speaker and trainer. Pieter has been awarded the Microsoft MVP Award since 2017, reflecting his unwavering passion and expertise in serving the community.
Read more about Pieter Nijs

Right arrow

What is .NET MAUI?

Writing mobile applications for different platforms is hard, especially when it comes to creating cross-platform apps that run smoothly on different devices and operating systems. .NET MAUI (Multi-platform App UI) is a framework that aims to simplify this process by allowing developers to build native and performant cross-platform desktop and mobile apps for iOS, macOS, Android, and Windows – all from a single code base.

In this chapter, we’ll take a look at the .NET MAUI framework. In order to thoroughly understand what this framework is and what it does, we’ll discuss its core concept, how it works, its features, and its benefits. We will also look at what is needed to start building a .NET MAUI app, installing the necessary bits, and creating a new app.

After reading this chapter, you will have a solid understanding of what the .NET MAUI framework is and how it works. You will also know how to install the necessary tools to start building...

Technical requirements

The final section of this chapter, Creating your first .NET MAUI app, guides you through everything you need to set up in order to create a .NET MAUI app.

The sample code can be found on GitHub at https://github.com/PacktPublishing/MVVM-pattern-.NET-MAUI/tree/main/Chapter02.

.NET MAUI in a nutshell

.NET MAUI is a framework from Microsoft for building native and performant cross-platform desktop and mobile apps for iOS, macOS, Android, and Windows, all from a single code base. Moreover, .NET MAUI’s reach extends beyond these primary platforms, thanks to Samsung’s efforts in adding support for Tizen OS. This additional support opens up possibilities for developers to target a wider variety of devices, such as smart TVs, wearables, and IoT devices that run on Tizen. However, for the purposes of this book, we’ll focus on building apps for iOS, macOS, Android, and Windows. Using .NET MAUI, developers can create native cross-platform user interfaces using XAML or C#. The key idea is to share your code, both business logic and UI, across all the supported platforms (Figure 2.1).

Figure 2.1: .NET MAUI high-level overview

Figure 2.1: .NET MAUI high-level overview

It’s important to notice that having this shared code base in .NET MAUI doesn’...

How does it work?

So now that we have a good understanding of .NET MAUI, you might wonder how this actually works. How does this .NET code eventually end up as a native app with a native UI on different platforms? It’s not magic, but to understand how it works, we need to take a look under the hood.

Native apps with .NET

At compile time, native apps for each selected platform are being created. The necessary parts of the .NET Base Class Library (BCL), which contains the .NET datatypes, interfaces, and libraries, are embedded in the native app and tailored to the target platform. The BCL relies on the .NET runtime to create an execution environment for your application code. For Android, iOS, and macOS platforms, the Mono runtime serves as the .NET runtime implementation that powers the execution environment. Meanwhile, on Windows, .NET CoreCLR is responsible for providing the runtime environment for your application.

This mechanism isn’t specific to .NET MAUI...

Creating your first .NET MAUI app

Let’s create our first .NET MAUI app! Before we can start writing any code, we need to set up our machine by installing some bits. So, let’s walk through these initial setup steps together and see what options we have. Once we’re set up, we’ll move on to the exciting part: creating a .NET MAUI app from scratch, step by step.

Setting up your machine

Getting started with .NET MAUI development is pretty simple, especially if you are using Visual Studio as your IDE. But even if you don’t want to use Visual Studio, the installation should be quite straightforward.

About .NET SDK versions and workloads

.NET MAUI is available from .NET 6, and at the time of writing the book, .NET 8 is the most recent version. It is important to note that every version of .NET comes with a specific support policy: there are Long-Term Support (LTS) releases, which provide 3 years of free support and patches, and there are Standard...

Summary

In this chapter, we provided an overview of .NET MAUI: what it is, how it works, and how to get started with creating a cross-platform app using .NET MAUI. We walked through the process of creating an app, complete with a splash screen and app icons. Additionally, we examined .NET Hot Reload and XAML Hot Reload, features that enable us to update code while the app is running, dramatically increasing our efficiency. Now that you have a holistic understanding of .NET MAUI and the MVVM design pattern, we can continue our journey by exploring how to effectively apply this pattern within the .NET MAUI framework.

In Chapter 3, Data Binding Building Blocks in .NET MAUI, we’ll explore the components available in .NET MAUI that enable us to build cross-platform apps using the MVVM pattern.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
The MVVM Pattern in .NET MAUI
Published in: Nov 2023Publisher: PacktISBN-13: 9781805125006
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Pieter Nijs

Pieter Nijs is a .NET consultant at Xebia in Belgium, with a keen interest in mobile and cloud development. He's been instrumental in diverse projects, from vast healthcare and telecom systems to compact LOB apps. Now, Pieter's exploring AI's potential to enhance customer projects innovatively. Passionate about technology, he actively experiments and shares knowledge as a conference speaker and trainer. Pieter has been awarded the Microsoft MVP Award since 2017, reflecting his unwavering passion and expertise in serving the community.
Read more about Pieter Nijs