Xamarin Forms control the color/title of the header bar

后端 未结 4 764
孤城傲影
孤城傲影 2021-02-02 00:08

I have the following form created with Xamarin Forms. I have drawn in a red rectangle to highlight the problem area. I need the blue color in the header to be a different colo

4条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-02 01:02

    Set the BarBackgroundColor of the NavigationPage. You can do something like this (in the most basic example sense):

            var nav = new NavigationPage
            {
                Title = "Detail"
            };
            nav.PushAsync(new ContentPage() { Title = "Home" });
            nav.BarBackgroundColor = Color.MediumPurple;
    
            var mdp = new MasterDetailPage()
            {
                Master = new ContentPage()
                {
                    Title = "Master"
                },
                Detail = nav
            };
            MainPage = mdp;
    

    The title of the ContentPage being presented by the NavigationPage is what will show the title on that bar.

提交回复
热议问题