TabbedPage Layout in .NET MAUI

The TabbedPage is a layout control in .NET MAUI that allows you to present content in a tabbed interface. Each tab displays a different content page, and users can switch between them by tapping on the tab headers.

Key Concepts

Creating a TabbedPage

You can create a TabbedPage programmatically in C# or define it in XAML.

XAML Example

Here's how you can define a TabbedPage with two content pages in XAML:

<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
            xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
            xmlns:local="clr-namespace:YourApp.Pages"
            x:Class="YourApp.MainPage">

    <local:HomePage Title="Home" IconImageSource="home.png" />
    <local:SettingsPage Title="Settings" IconImageSource="settings.png" />
    <local:ProfilePage Title="Profile" IconImageSource="profile.png" />

</TabbedPage>

In this example:

C# Example

You can achieve the same result programmatically:

using Microsoft.Maui.Controls;

namespace YourApp
{
    public partial class MainPage : TabbedPage
    {
        public MainPage()
        {
            InitializeComponent();

            Children.Add(new HomePage
            {
                Title = "Home",
                IconImageSource = "home.png"
            });

            Children.Add(new SettingsPage
            {
                Title = "Settings",
                IconImageSource = "settings.png"
            });

            Children.Add(new ProfilePage
            {
                Title = "Profile",
                IconImageSource = "profile.png"
            });
        }
    }
}

Customizing Tab Headers

You can customize the appearance of tab headers using the following properties:

Icons

Using icons can greatly improve the usability of your TabbedPage. Make sure your icon files are correctly placed in your project's resources.

Icon Examples
Home
Settings
Profile
Search
Notifications

TabbedPage in Action

Here's a visual representation of how a TabbedPage might look and function:

Home
Settings
Profile

Welcome to the Home Tab!

This is the content of the first tab. You can place any kind of UI elements here, such as labels, buttons, images, and more.

Common Use Cases

Platform Considerations

The appearance and behavior of the TabbedPage can vary slightly across platforms (iOS, Android, Windows, macOS). .NET MAUI provides ways to customize these platform-specific aspects.

Further Reading