Master Detail page Top menu bar background color

I have created the following xaml:

<?xml version="1.0" encoding="UTF-8"?>
<MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="WineCellar.HamburgerMenuPage"
Title="Wine App"
MasterBehavior="Popover"

>

<MasterDetailPage.Master>

        <ContentPage Padding="5"  Title="Wine App" Icon="hamburger_icon.png" >

        <ContentPage.Content>
            <StackLayout Margin="5,30,5,5">
                <Button Text="Menu Item"  Clicked="clicked_option1"/>

            </StackLayout>
        </ContentPage.Content>


   </ContentPage>

</MasterDetailPage.Master>

<MasterDetailPage.Detail>
    <ContentPage Padding="10" >
        <StackLayout Margin="5,30,5,5">
            <Label Text="Detail Page" />

        </StackLayout>
    </ContentPage>

</MasterDetailPage.Detail>

And the c#

using System;
using System.Collections.Generic;

using Xamarin.Forms;

namespace WineCellar
{
public partial class HamburgerMenuPage : MasterDetailPage
{
public HamburgerMenuPage()
{
InitializeComponent();
Detail = new NavigationPage(new LoginRegister());
IsPresented = false;
}

    void clicked_option1(object sender, System.EventArgs e ) {
        Detail = new NavigationPage(new LoginRegister());
        IsPresented = false;
    }
}

}

This works fine, but I would like to change the color of the background of the toolbar at the top of the page - is this possible in this case? (I am relatively new to Xamarin!)

Any help would be appreciated.

Answers

  • VijayPawar.0297VijayPawar.0297 USMember ✭✭

    make little change in your code

    From this

    Detail = new NavigationPage(new LoginRegister());

    to

    Detail = new NavigationPage(new LoginRegister(){ BarBackgroundColor = Color.LimeGreen, BarTextColor = Color.White });

    I hope this'll help you out.

Sign In or Register to comment.