Forum Xamarin.Forms

Change BarBackgroundColor dynamically

I have a NavigationPage with two buttons that navigate to PageA and PageB. I would like to give each page a different navigation bar color. What is the best way to do this? The last thing I tried was setting the value to the bindable property BarBackgroundColorProperty:

    public void OnPageAClick(object o, EventArgs e)
        var pageA = new PageA() { BackgroundColor = Color.White };
        pageA.SetValue(NavigationPage.BarBackgroundColorProperty, Color.FromRgb(255, 192, 0));

    public void OnPageBClick(object o, EventArgs e)
        var pageB = new PageB() { BackgroundColor = Color.White };
        pageB.SetValue(NavigationPage.BarBackgroundColorProperty, Color.FromRgb(0, 93, 125));

This isn't working though. Suggestions?

Best Answer


Sign In or Register to comment.