How to style MAUI ToolbarItems height and alignment on windows and android

KarstenNedergaardRasmussen-4470 20 Reputation points

It is possible to style Toolbar with ToolbarHandler but how is ToolbarItems and Tollbar height styled .

As image below show the ToolbarItem is not effected by ToolbarHandler settings on Windows and ToolbarHeight is not changed on Android


        public static MauiApp CreateMauiApp()
        ToolbarHandler.Mapper.Add("FixPlacement", (handler, view) =>
            handler.PlatformView.DefaultLabelPosition = Microsoft.UI.Xaml.Controls.CommandBarDefaultLabelPosition.Right;
            handler.PlatformView.VerticalAlignment = Microsoft.UI.Xaml.VerticalAlignment.Top;
            handler.PlatformView.Height = 35;
            handler.PlatformView.Padding = new Microsoft.UI.Xaml.Thickness(0);
            handler.PlatformView.Margin = new Microsoft.UI.Xaml.Thickness(0);
            handler.PlatformView.SetPadding(0, 0, 0, 0);
            handler.PlatformView.TextAlignment = Android.Views.TextAlignment.TextStart;
            handler.PlatformView.SetTitleMargin(0, 0, 0, 0);


        <Label Text="Test Title View" FontSize="8" HeightRequest="35"  VerticalOptions="Center" Margin="0" Padding="0"  ></Label>

                <FontImageSource Glyph="A" Color="BlanchedAlmond" Size="8"/>

Windows Screen Dump

Windows Screen Dump

Android Screen Dump

User's image

A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
1,417 questions
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
8,187 questions
{count} votes

Accepted answer
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 16,471 Reputation points Microsoft Vendor


    After investigation, it was not feasible to modify the ToolbarItem in the handler.

    The reason is that when using the handler, the ToolbarItem is already in the created state, but according to the ToolbarItem Class document, any changes will be ignored after the ToolbarItem is created.

    Any changes made to the properties of the toolbar item after it has been added will be ignored.

    Best Regards,

    Alec Liu.

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

0 additional answers

Sort by: Most helpful