Overview
Software development is evolving in such a way that cross-platform development is becoming increasingly important. In this article, we present a comprehensive overview of the features and capabilities of .NET MAUI (Multi-platform App UI), a robust solution for developing cross-platform desktop applications with C# and .NET 8.
Introduction to .NET MAUI
The technology allows developers to write code once and deploy it across multiple operating systems with .NET MAUI, which is an evolution of Xamarin.Forms. This reduces development time and improves consistency by allowing developers to write code once and deploy it across multiple operating systems.
Setting Up Our Development Environment
Before diving into .NET MAUI, make sure you have the necessary tools installed. You can use Visual Studio 2022 or Visual Studio Code with the .NET MAUI workload installed. Follow the official documentation for more information.
Creating a .NET MAUI Desktop Project
Start by making a .NET MAUI desktop application in your preferred development environment.
dotnet new maui-desktop -n ZiggyRafiq.CrossPlatformDesktopApp
cd ZiggyRafiq.CrossPlatformDesktopApp
This creates a new .NET MAUI desktop project named " ZiggyRafiq.CrossPlatformDesktopApp."
Designing the User Interface
The .NET MAUI project structure supports both desktop and mobile platforms. The application's user interface is defined in XAML, which provides a declarative way to describe its visual structure.
In the MainPage folder, open the MainPage.xaml file and modify it as follows:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="ZiggyRafiq.CrossPlatformDesktopApp.MainPage"
BackgroundColor="{DynamicResource PageBackgroundColor}">
<ScrollView>
<VerticalStackLayout
Padding="30,0"
Spacing="25">
<Image
Source="dotnet_bot.png"
HeightRequest="185"
Aspect="AspectFit"
SemanticProperties.Description="dot net bot in a race car number eight" />
<Label
Text="Welcome to .NET MANU Desktop by Ziggy Rafiq!"
Style="{StaticResource Headline}"
FontSize="50"
SemanticProperties.HeadingLevel="Level1"
HorizontalOptions="CenterAndExpand"
VerticalOptions="CenterAndExpand"
/>
<Label
Text="Welcome to
.NET Multi-platform App UI by Ziggy Rafiq"
Style="{StaticResource SubHeadline}"
SemanticProperties.HeadingLevel="Level2"
SemanticProperties.Description="Welcome to dot net Multi platform App U I Example by Ziggy Rafiq" />
<Button
x:Name="CounterBtn"
Text="Click me"
SemanticProperties.Hint="Counts the number of times you click"
Clicked="OnCounterClicked"
HorizontalOptions="Fill" />
</VerticalStackLayout>
</ScrollView>
</ContentPage>

Join the conversation! Your thoughts help the community grow.