A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
Hello @Vaibhav Methuku (ext) ,
Thanks for your question.
I tested on my device and it works. Please try again with StatusBarBehavior. You can refer to my following steps:
Step 1: Install latest community toolkit
- Right-click your project → click Manage NuGet Packages -> CLick Browser tab -> Find
CommunityToolkit.Mauiand install. - Or you can enter this in terminal:
dotnet add package CommunityToolkit.Maui
Step 2: Register community toolkit
Open MauiProgram.cs and update it:
using CommunityToolkit.Maui; // ← ADD THIS LINE
using Microsoft.Extensions.Logging;
namespace YourProjectName // ← Your project name
{
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.UseMauiCommunityToolkit() // ← ADD THIS LINE
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
});
#if DEBUG
builder.Logging.AddDebug();
#endif
return builder.Build();
}
}
}
Step 3: Add Namespace to App.xaml
Open App.xaml and add the toolkit namespace
<?xml version="1.0" encoding="UTF-8" ?>
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:YourProjectName"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
x:Class="YourProjectName.App">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
Key change: xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
Step 4: Change status bar color in AppShell.xaml
Open AppShell.xaml and add the StatusBarBehavior:
<?xml version="1.0" encoding="UTF-8" ?>
<Shell
x:Class="YourProjectName.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:YourProjectName"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
Shell.FlyoutBehavior="Disabled"
Title="YourProjectName">
<TabBar>
<ShellContent
Title="Home"
Icon="home.png"
ContentTemplate="{DataTemplate local:HomePage}"
Route="HomePage" />
<ShellContent
Title="Profile"
Icon="profile.png"
ContentTemplate="{DataTemplate local:ProfilePage}"
Route="ProfilePage" />
<ShellContent
Title="Settings"
Icon="settings.png"
ContentTemplate="{DataTemplate local:SettingsPage}"
Route="SettingsPage" />
</TabBar>
</Shell>
And in every page, you change the color: For ex: in HomePage.xaml
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
x:Class="TestStatusBar.HomePage"
Title="Home">
<ContentPage.Behaviors>
<toolkit:StatusBarBehavior StatusBarColor="Red" StatusBarStyle="LightContent" />
</ContentPage.Behaviors>
<VerticalStackLayout Padding="30" Spacing="25">
<Label
Text="Welcome to HomePage"
FontSize="24"
HorizontalOptions="Center" />
</VerticalStackLayout>
</ContentPage>
Step 5: Build and run
dotnet clean
dotnet build
I hope this addresses your question. If this response was helpful, please consider following the guidance to provide feedback.