.NET Multi-platform App UI (.NET MAUI) is a cross-platform framework for creating native mobile and desktop apps with C# and XAML.It is the evolution of the Xamarin.Forms cross-platform framework. .NET MAUI Release Candidate 2 was made available recently on April 26, 2022. This means that the product is supported by Microsoft for production apps.
I shall demonstrate how easy it is to get started with.NET MAUI on Windows. In order to follow on, you will need the following pre-requisites:
- You need a computer running on the Windows 10 or Windows 11 operating system
- Download & install Android Studio
- Install .NET MAUI on Windows by following these instructions
- If you do not already have VS Code, download and install it
Getting Started
dotnet new --list
This should will show you the available .NET application templates for cross platform applications:
Template | Short Name |
---|---|
.NET MAUI App (Preview) .NET MAUI App (Preview) | maui |
.NET MAUI Blazor App (Preview) | maui-blazo |
.NET MAUI Class Library (Preview) | mauilib |
.NET MAUI ContentPage (C#) (Preview) | maui-page-csharp |
.NET MAUI ContentPage (XAML) (Preview) | maui-page-xaml |
.NET MAUI ContentView (C#) (Preview) | maui-view-csharp |
.NET MAUI ContentView (XAML) (Preview) | maui-view-xaml |
Android Activity template | android-activity |
Android Application (Preview) | android |
Android Class Library (Preview) | androidlib |
Android Java Library Binding (Preview) | android-bindinglib |
Android Layout template | android-layout |
In today's exercise, we will create an app using the first maui template.
dotnet new maui -o maui2022cd maui2022
net6.0net6.0-androidnet6.0-iosnet6.0-maccatalystnet6.0-macosnet6.0-tvosnet6.0-windows
Run app on Windows
Run app in Android simulator from Visual Studio 2022 (Preview)
You can run the Android Device Manager directly from the following location:
C:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\IDE\Extensions\Xamarin\AndroidDeviceManager\AndroidDevices.exe
To run your MAUI app
from Visual Studio 2022 (Preview), first choose the emulator you want to use:
Run app in Android simulator from terminal window
pixel_4_-_api_30pixel_5_-_api_30
Start emulator pixel_4_-_api_30 | emulator -avd pixel_4_-_api_30 |
Start emulator pixel_4_-_api_30 after wiping all the data in the emulator | emulator -avd pixel_4_-_api_30 -wipe-data |
Making a tiny change
Conclusion
- change the picture on the main screen
- change the application icon that appears on the phone
- change the theme color of your app
No comments:
Post a Comment