Back to results for “Layouts”
.NET MAUI › XAML & UI Layouts

What is XAML and how is it used in MAUI?

Beginner

Answer

XAML (eXtensible Application Markup Language) is a declarative XML-based language for defining UI. In MAUI each page or view typically has a .xaml file for layout and a .xaml.cs code-behind. XAML elements map to C# objects, so <Label Text="Hi"/> is equivalent to new Label { Text = "Hi" }.
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             x:Class="MyApp.MainPage">
    <VerticalStackLayout Padding="20">
        <Label Text="Hello, MAUI" FontSize="24" />
    </VerticalStackLayout>
</ContentPage>
Real-world example A team keeps designers productive by letting them edit declarative XAML while developers handle logic in code-behind and view models.

Common follow-ups: Can you build UI without XAML? | What is code-behind?