Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

change color barBackgroundColor from MasterDetailPage

Luis_dmLuis_dm USMember ✭✭✭
edited December 2016 in Xamarin.Forms

I would like to know if it is possible to change the color of the "barBackgroundColor" of the "navigationPage", what happens is that I have a page where it has a list of colors and when you choose a color, it sends that color to the page of MasterDetail but nothing happens:,Do I need that it runs in real-time? a task?


        <local:MenuPage x:Name="ContePageMenu"/>
        <NavigationPage x:Name="Navigator"  BarBackgroundColor="{DynamicResource ColorAzul}" BarTextColor="{DynamicResource ColorBlanco}">


  • AlexDunnAlexDunn USMember ✭✭✭

    Yeah you can totally do this. In fact, the BarBackgroundColor is a fully bindable property.
    You could set up a ViewModel that acts as the BindingContext for your navigation page that has a Color property. You could then update that ViewModel's Color property from your list page and it will automatically update the color of bar accordingly.

  • TiagoRodriguesNesTiagoRodriguesNes USMember ✭✭

    Have you solved your problem?
    I have a similar 1.

    I've tried multiple approaches but the bar never changes color.

  • TiagoRodriguesNesTiagoRodriguesNes USMember ✭✭

    This did the trick for me.


        <NavigationPage x:Name="detailPage">


    detailPage.BarBackgroundColor = Settings.SECONDARY_COLOR;
  • HugoHugo USMember

    So .... this is how I did it...

        public MainPage(IEventAggregator ea)
            MasterBehavior = MasterBehavior.Popover;
            MenuPages.Add((int)MenuItemType.Browse, (NavigationPage)Detail);
            _currentPage = (NavigationPage) Detail;
            ea.GetEvent<LoadSheddingStatusEvent>().Subscribe(result =>
                    _currentPage.BarBackgroundColor = result.Color;
        public async Task NavigateFromMenu(int id)
            if (!MenuPages.ContainsKey(id))
                switch (id)
                    case (int)MenuItemType.Browse:
                        var dashB = new NavigationPage(new DashboardPage());
                        dashB.BarBackgroundColor = Color.Gray;
                        MenuPages.Add(id, dashB);
                    case (int)MenuItemType.About:
                        MenuPages.Add(id, new NavigationPage(new AboutPage()));
            var newPage = MenuPages[id];
            if (newPage != null && Detail != newPage)
                newPage.BarBackgroundColor = _currentPage.BarBackgroundColor;
                Detail = newPage;
                _currentPage = (NavigationPage)Detail;
                if (Device.RuntimePlatform == Device.Android)
                    await Task.Delay(100);
                IsPresented = false;
Sign In or Register to comment.