liveBook · Manning

ContentPage

As explained in .NET MAUI in Action

ContentPage is a .NET MAUI page type that hosts a single content view for a full-screen application page.

ContentPage is the standard .NET MAUI page for a full-screen app view. It hosts one View through its Content property, making it the usual starting point for building a screen. section 2.3 section 7.1

Build a ContentPage by choosing how to assign its single content view:

  • Use XAML by placing a layout or control between the opening and closing ContentPage tags. section 7.1
  • Use C# by assigning a View, such as VerticalStackLayout, to Content in the page constructor. section 7.1
  • Assign a layout when the screen needs multiple controls; use a single control directly when the page is simple. section 7.1

A simple button page

Declare a ContentPage in XAML and place one Button inside it: <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="AlohaWorld.MainPage"><Button Text="Click me" FontAttributes="Bold" HorizontalOptions="Center" /></ContentPage>. For a larger screen, assign a ScrollView containing a VerticalStackLayout, then place the controls inside the layout.

How .NET MAUI in Action covers it

How deep it goes
Defines the Content property and XAML or C# assignment patterns, but does not detail page implementation internals.
Examples
Uses a single Button, or a ScrollView containing a VerticalStackLayout with images, labels, and buttons.
What it assumes
Assumes basic .NET MAUI page structure while teaching that pages host Views through a single Content property.
What you can do after
Build a screen from scratch by assigning a layout or control through XAML or C#.
How it connects
Connects pages with View, layouts, controls, navigation, Shell, and page lifecycle methods.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of .NET MAUI in Action. The section links point to the parts of the book it draws on.