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?

MasterDetail.xaml

 <MasterDetailPage.Master>
        <local:MenuPage x:Name="ContePageMenu"/>
      </MasterDetailPage.Master>
      <MasterDetailPage.Detail>
        <NavigationPage x:Name="Navigator"  BarBackgroundColor="{DynamicResource ColorAzul}" BarTextColor="{DynamicResource ColorBlanco}">
          <x:Arguments>
            <local:ListaPedidosPage/>
          </x:Arguments>
        </NavigationPage>
      </MasterDetailPage.Detail>

Answers

  • 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.

    XAML

    <MasterDetailPage.Detail>
        <NavigationPage x:Name="detailPage">
    

    C#

    detailPage.BarBackgroundColor = Settings.SECONDARY_COLOR;
    
Sign In or Register to comment.