Reputation: 41
I want to hide Nav bar on the main-start page of my app. but want to make it display with a title and back button on the second page. This is something I did, but it appears on the main page too.
In App.xaml.cs, I used this:
MainPage = new NavigationPage(new MainPage());
In corresponding login page, I created this:
private async void LoginPage_Clicked(object sender, EventArgs e)
{
await Navigation.PushAsync(new LoginPage());
}
When the user will click it'll take to the second page(login page).
Also, how can I change the color of the nav bar?
Upvotes: 2
Views: 7306
Reputation: 10224
As a bonus, you can also remove it via xaml:
<ContentPage ...namespaces... NavigationPage.HasNavigationBar="False">...
Upvotes: 6
Reputation: 43
In App.cs use
MainPage = new YourProjectNamespace.MainPage();
This will hide your navigation bar on your first page
Upvotes: -1
Reputation: 16199
In the constructor of the page you want to hide the navigation bar, use the following code.
Xamarin.Forms.NavigationPage.SetHasNavigationBar(this, false);
To change the color of the NavigationBar, you can do this.
new NavigationPage(new MainPage())
{
BarBackgroundColor = Color.FromHex("#000000"),
BarTextColor = Color.White
};
Upvotes: 6