How to change NavBar colour of MasterMainPage in Xamarin

后端 未结 2 629
忘了有多久
忘了有多久 2021-01-22 13:44

I\'m building a Xamarin cross-platform App!

The problem is I want to change the colour of NavigationBar of MainPage which is MasterPage

相关标签:
2条回答
  • 2021-01-22 14:35

    Here, when you assign App.xaml's MainPage, a NavigationPage, it shows it's own NavigationBar. Under the hood, your MasterDetailPage also shows the NavigationBar. Thus, you are viewing two NavigationBars.

    Go to your MainPage.xaml.cs backend page and in the Constructor, write the line:

    NavigationPage.SetHasNavigationBar(this, false);
    

    Thus, your MainPage.xaml.cs should look like :

    public MainPage()
    {
        NavigationPage.SetHasNavigationBar(this, false);
        InitializeComponent();
        ......
    }
    

    This will hide the NavigationBar of MasterDetailPage.

    0 讨论(0)
  • 2021-01-22 14:42

    The NavigationPage has a BarBackgroundColor property which you can set.

    Referred this

    var nav = new NavigationPage(new ContentPage { Title = "Page" } );
    nav.BarBackgroundColor = Color.Blue;
    
    0 讨论(0)
提交回复
热议问题