2
votes

I already tried for chnage the Navigation Bar Background Color but its not working.

<ResourceDictionary>
            <Style TargetType="NavigationPage">
                <Setter Property="BarBackgroundColor" Value="#6eb43a"/>
                <Setter Property="BackgroundColor" Value="#6eb43a"/>
            </Style>
        </ResourceDictionary>

BarBackgroundColor = Not Working BackgroundColor= Working

so when I am using BackgroundColor(problem is that it change the background color also) then it will effect on Navigation Background but BarBackgroundColor not working. Have any solution for change the BarBackground Color globally so that it will effect on whole project?

4
Add into App.xaml under <Application.Resources> ... </Application.Resources> - Prasanth
this code is already inside App.xaml - Vidhya
Xamarin.Forms version? - FreakyAli
I am using katest version - Vidhya

4 Answers

1
votes

Try change it from code behind:

MainPage = new NavigationPage(new MainPage())
            {
                BarBackgroundColor = Color.FromHex("#6eb43a"),
                BarTextColor = Color.Black,
            };

barbackgroundcolor

1
votes

For those using the new Xamarin.Forms.Shell layout, you do this by setting the background color directly on the Shell node

<Shell BackgroundColor="#FFFFFF">...

This will then flow down the hierarchy, which you can override on child nodes as you require.

1
votes

Try after InitializeComponent();

((NavigationPage)Application.Current.MainPage).BarBackgroundColor = Color.White;

OR

((NavigationPage)Application.Current.MainPage).BarBackgroundColor = Color.FromHex("#2196f3");

It will change the navigationbar color of all pages.

0
votes

You have already written your style in App.Xaml. Now you just have to call that style in your ContentPage xaml file, so that it will set for all the pages.

 Style="{DynamicResource NavigationPage}"

Let me know if this helps you.