Home > Enterprise >  How do I change app shell selected tab colour, MAUI?
How do I change app shell selected tab colour, MAUI?

Time:12-14

I am building a windows app using .NET MAUI and I have a flyout shell with some tabs. I would like to change the colour of the selected item, specifically the little blue bar that shows at the left side of a selected item. shown here

I can not find anything that changes this, does anyone know if this is even possible?

CodePudding user response:

It seems this is more of style question. It is bit hard to help/answer your question without looking at the code. Normally color value is stored at XAML or CSS (if it is blazor/razor). Changing color is totally possible for sure.

CodePudding user response:

You can use the Shell.MenuItemTemplate to customize the item.

  <Shell.MenuItemTemplate>
        <DataTemplate>
            <Grid ColumnDefinitions="0.2*,0.8*">
                <Image Source="{Binding Icon}"
                       Margin="5"
                       HeightRequest="45" />
                <Label Grid.Column="1"
                       Text="{Binding Text}"
                       FontAttributes="Italic"
                       VerticalTextAlignment="Center" />
            </Grid>
        </DataTemplate>
  </Shell.MenuItemTemplate>

  <Shell.Resources>
        <Style TargetType="Image" Class="FlyoutItemImageStyle">
            <Setter Property="Background"  
            Value="AliceBlue"></Setter>
        </Style>
  </Shell.Resources>

For more information you can refer to Define MenuItem appearance. In addition, I find a sample and you can check this How to set the Color of Icons in FlyoutItems in AppShell.

  • Related