Loading...
Today we will get acquainted with an interesting topic - the development of mobile applications using the .NET MAUI framework. Stands for Multi-platform App UI. MAUI is the future of portable mobile application development using .NET technologies. is also an extension of the Xamarin framework that provides more opportunities for developing portable mobile applications. With .NET MAUI, you can build applications that will run on different platforms, such as Android, iOS, and Windows, using common code in the C# programming language.
Advantages of developing on MAUI: 1. Cross-platform: .NET MAUI provides the ability to develop mobile applications that work on different platforms. This saves time and effort because one code can be used on all platforms. 2. Shared code: With .NET MAUI, developers can write shared code in C#, which simplifies application development and maintenance. You don`t need to write separate code for each platform, which speeds up development and reduces errors. 3. Native Interface: Your app will look and work on every platform as expected from a native app. 4. Wide choice of components: You can use many ready-made components and libraries available for .NET MAUI. This gives you the opportunity to quickly build functional and aesthetically attractive applications. 5. Growing support: .NET MAUI is built on the strong foundations of .NET and Xamarin, and has a large developer community that actively helps each other and provides various resources such as documentation, tutorials and support forums.
All these advantages make development on .NET MAUI more attractive for new projects, allowing you to create impressive cross-platform applications faster and at a lower cost. You can create innovative projects, share your ideas with the world and get recognition for your efforts.
.NET MAUI combines Android, iOS, macOS, and Windows APIs into a single API that empowers developers to do one-time development anywhere, giving them additional access to every aspect of each native platform. In .NET MAUI, you write code that interacts with the .NET MAUI API (1). .NET MAUI then directly uses the platforms native APIs (3). In addition, the application code can directly interact with the platform API (2) if necessary.
Creating a .NET MAUI project Consider its structure: The Platforms folder contains subdirectories of each individual platform. The folder contains code files to interact with a specific platform. The Resources folder contains resource files used in the program, such as font files, icons, images, etc. App.xaml: Defines the resources common to the entire application App.xaml.cs: The C# code file that starts the execution of the application AppShell.xaml: Defines the common visual interface of the multipage application AppShell.xaml.cs: The C# code file that is associated with the AppShell.xaml file and defines the associated application logic MainPage.xaml: a visual interface file for a single MainPage in the form of xamlMainPage.xaml.cs: a file that contains the MainPage page logic in C#.
MauiProgram.cs: contains the MauiProgram class, which defines the starting class of the program and a number of general settings for the program.
Project launch. If the working machine on which the development is carried out supports virtualization, we can use emulators: Android from Microsoft or Android Player to debug applications. If we have an Android device, we can use it for testing. To do this, you need to connect this device to a computer using a USB cable. And on the mobile device, set the developer mode. To install the device, go to Visual Studio in the launch devices field and select the Android local Devices item in the list and select the connected Android device in the menu for this item. And after launching the project for execution on the mobile device, the interface of our program will appear: To create an iOS program from Visual Studio on Windows. Technically, a MacBook is required to compile the program for iOS. Also, all the necessary tools for development under Maui must be installed on Mac OS, the latest version of XCode must be installed.
XAML is used to define the GUI in .NET MAUI. Represents an xml-based markup language for creating objects declaratively. Using XAML has some advantages. With the help of XAML, we can separate the graphical interface from the program logic, thanks to which different specialists can work relatively autonomously on different parts of the program: on the interface - designers, on the logic code - programmers. Secondly, XAML allows you to describe the interface in a more understandable way, such code is much easier to maintain and update. In general, XAML allows you to organize the entire user interface as a set of pages, similar to how it is done in HTML.
The architecture of applications in .NET MAUI is based on the MVVM (Model-View-ViewModel) pattern, which allows for efficient organization, display and processing of data in the application. The main components of the .NET MAUI architecture include: View - the view or user interface Model - the model or data used in the application View Model - the intermediate layer between the view and the data that allows them to interact. The advantage of using is less coupling between components and division of responsibility between them. The Model is responsible for the data, the View is responsible for the graphical interface, and the ViewModel is responsible for the application logic. The ease of implementing the MVVM pattern in .NET MAUI and C# is made possible by the built-in binding mechanism. As a rule, the ViewModel object is set through the Binding Context property of the visual element. All interactions between data and the visual interface go through the View Model. When using a pattern as a view, a page usually appears, and one view is associated with one view model (ViewModel). At the same time, the same ViewModel can be used by several views. It is worth noting that in this regard, the View Model knows nothing about the view, what it is, what controls it contains. The View Model defines the processing logic without any connection to the graphical interface.
.NET MAUI is a powerful tool for developing portable mobile applications. And, if you need to build an app for multiple platforms, you should consider using .NET MAUI. It provides developers with convenient tools to develop applications using shared C# code, which can significantly reduce development time and cost.
https://youtu.be/n21lact2a54