XAML MAUI Basic View Types
Learn about the basic view types supported by the .NET MAUI version of XAML.
Views, also known as controls, are individual XAML markup components that can be placed on content pages. These represent all types of interactive and noninteractive visual elements, such as text boxes, labels, buttons, progress bars, drawings, etc.
XAML views can be broadly separated into several categories. We'll look at them all, starting with the most basic ones.
Let's look at the basic view types supported by .NET MAUI version of XAML in the following project setup:
<?xml version="1.0" encoding="utf-8"?> <resources> <color name="colorPrimary">#512BD4</color> <color name="colorPrimaryDark">#2B0B98</color> <color name="colorAccent">#2B0B98</color> </resources>
Basic controls
These controls represent simple single-functionality elements. This category includes buttons, images, labels, text boxes, etc.
Image
In the project above, we have an example of the Image
control inside the MainPage.xaml
file on lines 12–16. As the name suggests, the purpose of this element is to display an image. The image is defined by the Source
attribute. There are multiple ways of defining the image source, and this example points to a file with the name dotnet_bot.png
. The file referenced by this attribute would be located inside the Images
folder in the Resources
folder.
Label
This element displays a piece of text that cannot be edited. We have two examples of this element inside the MainPage.xaml
file. They can be found on lines 18 and 24, respectively.
The Text
attribute that we have on line 19 represents the label text ...