Reputation: 1959
Iam developing a xamarin forms application.In my application,the navigation Bar color is blue. I want navigation bar color of one specific page as white. I achieved that through
((NavigationPage)Application.Current.MainPage).BarBackgroundColor = Color.White;
Now Iam facing a problem.The page which have white navigationbar will pop back to previous page after certain time.After the popasync, previous pages which have blue navigation bar will also turn to white color. How to avoid that?.
namespace sample
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class ApprovedAnimation : ContentPage
{
public ApprovedAnimation ()
{
InitializeComponent ();
((NavigationPage)Application.Current.MainPage).BarBackgroundColor = Color.White;
Device.StartTimer(TimeSpan.FromMilliseconds(3000), () =>
{
Navigation.PopAsync();
return false;
});
}
}
}
Upvotes: 1
Views: 210
Reputation: 329
You need to set back the navigation color on the page itself using this method
protected override void OnDisappearing()
{
base. OnDisappearing();
((NavigationPage)Application.Current.MainPage).BarBackgroundColor = Color.Blue; // this will set back the normal color
}
Upvotes: 2