Understanding the structure of XAML
XAML files have the .xaml
extension, for example, MainPage.xaml
, in the out-of-the-box program as shown in Chapter 1. Let’s examine this file to explore XAML for its layout and declaration of controls.
Just an overview
This chapter will only scratch the surface of creating XAML layout and controls. Chapter 4 and Chapter 5 will cover the details on controls and layouts, respectively.
A .NET MAUI page that is written in XAML will have a name in the format MyName.xaml
, and associated with that page will be a code-behind page (explained shortly) in the format MyName.xaml.cs
.
At the top of the XAML page is a declaration that this file is, in reality, an XML-type file. That declaration must be at the very top of every .
xaml
file.
There are different types of pages (also called views). The most common is ContentPage
, and here MainPage
is created as ContentPage
using this code:
<?xml version="1.0" encoding="utf...