Reputation: 465
Using Xamarin Forms Pcl & Prism Library in side APP.CS
protected override void OnInitialized()
{
//Initialize();
InitializeComponent();
NavigationService.NavigateAsync("NavigationPage/MainPage");
}
protected override void RegisterTypes()
{
Container.RegisterTypeForNavigation<NavigationPage>();
Container.RegisterTypeForNavigation<MainPage,MainPageViewModel>
("MainPage");
}
inside MainPage.Xaml
Title="Main Page"
NavigationPage.HasNavigationBar="True"
NavigationPage.BarTextColor="Black"
NavigationPage.BarBackgroundColor="Red"
but it Never Changes the NavigationBar Color.
Upvotes: 0
Views: 3689
Reputation: 432
with Prism follow this link: https://prismlibrary.com/docs/xamarin-forms/navigation/navigation-basics.html where T in "Register" section is your custom NavigationPage (in the example below AppInfoNavPage
) where you set the various attributes in the constructor like this
public partial class AppInfoNavPage : NavigationPage
{
public AppInfoNavPage()
{
InitializeComponent();
BarBackgroundColor = App.Data.DarkBlue;
BarTextColor = Color.White;
}
}
Upvotes: 0
Reputation: 788
I created my own Navigation page
public class CustomNav : NavigationPage
{
public CustomNav()
{
//here you can set all you styles
}
}
And when registering
Container.RegisterTypeForNavigation<CustomNav>("NavigationPage");
So when I use I can reference it NavigationPage
Upvotes: 0
Reputation: 5799
I would suggest opening an issue on Bugzilla with Xamarin. That doesn't actually work currently in a Xamarin Forms app without Prism. If you are using a single style in your app you could just add the following style to your App.xaml
<Application.Resources>
<!-- Application resource dictionary -->
<ResourceDictionary>
<Style TargetType="NavigationPage">
<Setter Property="HasNavigationBar" Value="True" />
<Setter Property="BarTextColor" Value="Black" />
<Setter Property="BarBackgroundColor" Value="Red" />
</Style>
</ResourceDictionary>
</Application.Resources>
Otherwise I might suggest implementing a NavigationPage that is INavigatingAware
and use the NavigationParameters to help it figure out what styling you need to use.
Upvotes: 1