H.A.H.
H.A.H.

Reputation: 3917

Change ToolbarItem Text/Icon parameters

I am new to MAUI. And I haven't done anything complex with Xamarin as well.

The application I am testing with, has Shell navigation. And I can't find a way to change the toolbar items.

I would like to be able to change either the FontSize of the text, or the color of the SVG image. And I do not want those changes to affect the rest of my application, if possible. But if there is no other way, I can live with it.

I have managed to add styling to buttons, Labels etc... If styling is an option to this, it will be even better.

If I am on the wrong path, if you point me out why, I will be also grateful.

Thank you in advance!

Upvotes: 2

Views: 3897

Answers (2)

Liyun Zhang - MSFT
Liyun Zhang - MSFT

Reputation: 14469

If you want to just change a part of pages in your project. You can try to use a <Shell.TitleView> instead of the <Shell.ToolBarItem> in the content pages you want. Such as:

<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         x:Class="MauiAppTest.MainPage">
<Shell.TitleView>
    <HorizontalStackLayout Margin="5" HorizontalOptions="End">
        <Label Text="hello" TextColor="Red" FontSize="Medium" VerticalOptions="Center" HorizontalOptions="End" />
        <Image Source="your image" Margin="10" Background="green"/>
    </HorizontalStackLayout>
</Shell.TitleView>

Upvotes: 2

petit
petit

Reputation: 11

You can change style of TabBar in Style.xaml in path \Resources\Style\. Search in file for Shell.TabBarForegroundColor. You will get TargetType="Shell" and this is style for AppShell.xaml.

Upvotes: 1

Related Questions