MAUI: Hello World
1.1 MAUI: Introduction to .NET MAUI- creating project and run.
Tools
Download and install Visual Studio 2022:
In Visual Studio Installer choose: Mobile development with .NET
ensure that .NET MAUI is enabled in Optional
Create new project: MAUI
Open Visual Studio 2022 on your right you should see “Create new project”:
Use search entry to find “maui” project
Name project and select location and “Create” project
Success project view
Single project
Single project is unified way to share common code and resources as fonts, images, icons and other files.
Single project solution gives also easy way possibility to support platform specific / operation specific cases.
Dependencies
How you can see bellow One project and in Dependencies there are libraries related with Android, iOS, Mac Catalyst, Windows they enable work on those OS (operation systems/platforms).
Platforms
In “Platforms” Folder(Catalogue) there are subfolders for each supported operation system: Android, iOS, Mac Catalyst, Windows.
Here you can make operation system/platform specific code modifications.
Resources
Having Resources as Images, Fonts in one place is great achievement and productivity booster. Resources are are platform specific thing and each platform handles it different way, but for developer comfort and development speed resources are kept in common place but also could be stored per platform.
Common resources:
Platform specific resources:
MauiProgram.cs
MauiProgram is main class where app is created and all configuration happens:
App.xaml and XAML files
EXtensible Application Markup Language (XAML)files are files used to create User Interface (UI) / Graphic User Interface (GUI).
In Microsoft app world XAML is common language but have many dialects some them are used in WPF, UWP, XAMARIN.FORMS.
App.xaml is special, holds whole application, first that create others.
Start — App run
Developer can run app(program) and chosen platform(Android, iOS, Mac Catalyst, Windows) on real device, remote device, emulator or simulator.
Android Emulator Run
Hot Reload
Notice when running application there is “NEW” red flame icon it is Hot reload.
Hot reload is next productivity booster that enables changing UI in when app is running(in runtime):
Sometimes you will need to “Restart Application” to see more complex UI changes.
iOS Simulator run
iOS run require real iPhone device connected via cable or pairing Mac remote machine:
Windows run
When you are running on windows it can be faster to deploy and test your app on Windows.
Summary
After successful download on windows you should be able to run and edit your code on any supported platform on real device, emulator, simulator via remote device.
Developer can manipulate UI on Android and iOS via “Hot reload” mechanism.