In this post we are going to build and run our first .NET MAUI app. I will go step by step on how you can do this. If you are experienced with programming and have already got Microsoft Visual Studio, please feel free to skip the next few steps.
First we need an IDE(Integrated Development Environment) to edit and compile code. I will be using Visual Studio, which is free to download from visualstudio.microsoft.com/vs/community
During installation you will need to select the .NET Multi-Platform App UI development. Once we’ve downloaded Microsoft Visual Studio, we will start our project.
Select “Create a new project”.
Select C# in the dropdown menu and select Android in the second dropdown menu. Select “.NET MAUI App” and click next.
Choose a project name and a location to save to. Untick “Place solution and project in the same directory”. Click next.
Choose .NET 7.0 (Long Term Support) and click “next”. This will bring you to a screen that looks like this.
What the default MainPage.xaml (what the app will look like) looks like:
What the default MainPage.xaml.cs (this is the code-behind) looks like:
Click the “Windows Machine” button in the Visual Studio toolbar to build and run the app.
You will be prompted to enable Developer mode if it has not already been enabled. Go to Settings>System>For developers and toggle to on.
The following basic app appears. This app has a “Click me” button which can be clicked and then counts the number of clicks.
Next we’re going to edit the code:
Congratulations on building and editing your first .NET MAUI app!