MaxFmi
MaxFmi

Reputation: 71

Change the BackgroundColor of Xamarin.Forms Shell top TabBar (without changing the NavigationbarColor)

It is possible to change the top TabBars BackgroundColor by setting "Shell.BackgroundColor". But that will also change the BackgroundColor of NavigationBar (Green area).

enter image description here

Does anyone know how to change the BackgroundColor of the top TabBar without changing the BackgroundColor of NavigationBar?

What's also strange. By setting "Shell.BackgroundColor" both colors will be set (Shell top TabBar and NavigationBar), but they are slightly differently colored. Does anyone know why?

Upvotes: 0

Views: 698

Answers (1)

MaxFmi
MaxFmi

Reputation: 71

It seems like there is already a GitHub issue for that https://github.com/xamarin/Xamarin.Forms/issues/6711

I hope this is helpful

public class CustomShellRenderer : ShellRenderer
{
    protected override IShellSectionRenderer CreateShellSectionRenderer(ShellSection shellSection)
    {
        var renderer = base.CreateShellSectionRenderer(shellSection);
        if (renderer != null)
        {
            var a = (renderer as ShellSectionRenderer);
            (renderer as ShellSectionRenderer).NavigationBar.Translucent = false;
        }
        return renderer;
    }

    protected override IShellItemRenderer CreateShellItemRenderer(ShellItem item)
    {
        var renderer = base.CreateShellItemRenderer(item);
        (renderer as ShellItemRenderer).TabBar.Translucent = false;
        return renderer;
    }
}

Or set Shell.BackgroundColor to an empty value -> Shell.BackgroundColor=""

Upvotes: 1

Related Questions