Hello everyone,
I want to change the navigation bar background color and text color. But i don't know how to set it.
I can only set the bar background color in App.cs file.
MainPage = new NavigationPage(new MainPage()) { BarBackgroundColor = Color.Green };
But i want to change this setting in other page.
var work=new WorkPage();
this.Navigation.PushAsync(work);
Actuall, i want to set the BarBackgroundColor to Red when the WorkPage is show.
I set it in other page as this.
`public partial class WorkPage : ContentPage
{
public WorkPage ()
{
InitializeComponent ();
var baseModel= new RootViewModel ();
baseModel.BarBackgroundColor = Color.Red;
baseModel.BarTextColor = Color.Accent;
this.BindingContext = baseModel;
this.SetBinding (NavigationPage.BarBackgroundColorProperty, "BarBackgroundColor");
this.SetBinding (NavigationPage.BarTextColorProperty, "BarTextColor");
}
}`
public class RootViewModel:BindableObject
{
public Color BarBackgroundColor{get;set;}
public Color BarTextColor{get;set;}
public string BarTitle{get;set;}
}
but it did not work for Android. Can anyone help me for this? Thanks in advance!