Introduction

Microsoft has officially released the MAUI recently. Using MAUI – Multi-Platform Application UI framework we can develop native mobile and desktop applications with C# and XAML. MAUI is an open-source cross-platform framework to develop native Android, iOS, and Windows applications from a single code base.

In this article, we will learn what is MAUI, when to choose MAUI, different categories of MAUI, and get started with MAUI application development.

Prerequisites

  • Visual Studio 2022 preview

The first requirement for MAUI development is, that you need to have Visual Studio 2022 Preview version. At this time of article writing, MAUI is only available in this version. You can download and install the Visual Studio 2022 Preview from here. For this demo purpose, I have used Visual Studio Preview Version 17.3.0 Preview 5.0.

Moreover, you need to select and install .NET Multi-platform App UI development from the workload list as illustrated below. Once installed, restart your Visual Studio or machine as well.

When to choose MAUI?

  • Useful for developers who need to build cross-platform applications using C# and XAML from a single code base. Additionally beneficial for .Net developers and Xamarin developers to build all types of apps from a single solution that can be run on cross-platform.
  • Can be utilized when you need to develop an application for cross-platform using the same business logic, and code to fulfill the same requirements.
  • It saves time as we can utilize the same design, layouts, and also business logic across various platforms.
  • You will not need mobile developers and desktop developers and so on for the same kind of application development for different devices and OS as MAUI serves all purposes.
  • Additionally, because of time and resources, your project cost will be reduced significantly.

Let’s move to the creation of the MAUI Application

Create First MAUI App

In this section, we will create an MAUI application that can be run on cross-platform and get familiar with the development.

Open Visual Studio 2022 preview and click on Create a new project as shown below.

Then, search for MAUI in the project template search box.

In this step, you will see different categories of MAUI such as . NET MAUI App, .NET MAUI Blazor App, .NET MAUI Class Library.

.NET MAUI App: Using this we can develop applications for iOS, Android, Mac Catalyst, macOS, Tizen, and Windows from a single code base.

.NET MAUI Blazor App: This option is for MAUI app development using Blazor and these applications are able to run in iOS, Android, Mac Catalyst, macOS, Tizen, and Windows.

.NET MAUI Class Library: This is for building a class library using .NET MAUI which is able to run in Android, iOS, Mac Catalyst, macOS, Tizen, and Windows

In this part of the article, we will create an application using .NET MAUI App template.

Give project name, location, and click on Next as shown below.

Then, select framework .NET6 (long-term support) as portrayed below.

Then your MAUP application will be created as shown below.

Default Project Structure

As you can see there are different folder structures for different platforms such as Android, iOS, Mac Catalyst, Tizen, and Windows.

Now you can run and see the default MAUI project.

Running Applications for Different Platforms

Running and debugging is the same as usual, however, you can see different running and debugging options using emulators for different devices. So, from these options, you can export the application to various platforms.

Running for Windows

Let’s select Windows Machine in the run options and see. If you are using .NET MAUI on your machine for the first time, you may get a message box like the one below.

Enable Developer Mode

When you run your MAUI app in Windows and if get an error like the below. Then you need to update the setting in your machine.

Solution: Enable the target device to developer mode from your setting as depicted in the below screen.

After enabling the developer mode of your device then you can successfully run your MAUI app in windows which will look like as illustrated below.

Cheers! We successfully ran our first MAUI app in Windows.

Running for Android

Select Android Emulator and run. You may require to configure an emulator if you are using your machine for the first time. Below is the output in my machine which I have used for the first time selecting the Android emulator in the run option.

You can create an Android Device and run the app there. Similarly, can do for all other devices using the appropriate emulator and simulator.

Summary

In this article we learned what is MAUI, it’s uses and benefits, and the types of MAUI application development. Additionally, we created a .NET MAUI application and got familiar with it.

I hope you find it helpful. If you have any queries, concern please write in the comment section.

In the Next part of the article series, we will build .NET MAUI Blazor application.

Reference

Microsoft

Leave a Reply

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