Hi
Wondering if is possible to change the navigation bar background programmatically
without using renderers.
I have an app that uses prism not that matters .
I have a masterpage and in my app.xaml I have the following
<Style TargetType="NavigationPage">
<Setter Property="BarBackgroundColor" Value="OrangeRed" />
<Setter Property="BarTextColor" Value="Blue" />
</Style>
so far so good!!!
Now when I go to a particular page I need to change the BarBackgroundColor.
Whatever I tried did not work(below code anywhere is always null!!)
//does not work as navigationPage is null
var navigationPage = App.Current.MainPage as NavigationPage;
navigationPage.BarBackgroundColor = Color.Red;
I even created a class :MyNavigationPage and injected it and still does not work
public class MyNavigationPage : Xamarin.Forms.NavigationPage, INavigationPageOptions, IDestructible
{
public MyNavigationPage()
{
}
}
private readonly myNavigationPage navPage;
public MenuViewModel(INavigationService navigationService,
MyNavigationPage navigationPage) : base(navigationService)
{
this.navPage = navigationPage;
}
private void OnMenuItemTapped(MasterMenuItem menuItem)
{
navPage.BarBackgroundColor=Color.Red;
}
}
any samples out there where it works!!!
Is this a bug?
many thanks