Basic XAML Syntax

XAML is the dialect of XML that .NET MAUI uses as the markup language to define user interfaces. It adheres to a specific MAUI schema. This schema defines which elements can be used inside the markup. A noteworthy feature of MAUI-specific XAML schema is that almost all elements represent classes. For example, the <ContentPage /> element corresponds to the ContentPage class. The <App /> element corresponds to the App class. And it's true for almost all other elements.

While XAML elements primarily represent classes, their attributes usually represent properties of those classes. On the other hand, attribute values can represent anything from basic text to event handler methods.

We'll have a look at the fundamentals of the XAML syntax. And we'll look at various ways of referring to framework components inside the markup.

Basic XAML structure

XAML files have the xaml extension. By default, the first XAML file that's used during the application startup is called App.xaml. Its structure looks similar to the following:

Get hands-on with 1200+ tech skills courses.