Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove navigation bar in contentpage Xamarin

I am trying to remove navbar from my pages in Xamarin Forms, but I am not able to get it working. I have tried by adding NavigationPage.SetHasNavigationBar(this, false); inside constructor of page eg.

public RegisterUser ()
{           
    InitializeComponent ();
    NavigationPage.SetHasNavigationBar(this, false);
}

And / or by adding NavigationPage.HasNavigationBar="False" inside xaml page

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="PetApp.Pages.RegisterUser"
             NavigationPage.HasNavigationBar="false">

But none of those helps.

Is there some better best practice to just show clean page with scrollview or should it be possible to remove navbar totally?

It works in Mainpage but not the rest of pages that I am navigating to via

await Navigation.PushAsync(new NavigationPage(new RegisterUser()));
like image 284
Eldlabs Avatar asked Jul 13 '18 19:07

Eldlabs


People also ask

How to hide Navigation bar in Xamarin Forms?

NavigationPage. SetHasNavigationBar(this, false);

How do I hide the navigation bar?

Way 1: Touch “Settings” -> “Display” -> “Navigation bar” -> “Buttons” -> “Button layout”. Choose the pattern in “Hide navigation bar” -> When the app opens, the navigation bar will be automatically hidden and you can swipe up from the bottom corner of the screen to show it.

What is flyout in xamarin?

The navigation experience provided by Xamarin.Forms Shell is based on flyouts and tabs. A flyout is the optional root menu for a Shell application, and is fully customizable. It's accessible through an icon or by swiping from the side of the screen.


1 Answers

I found a solution, instead of using Navigation.PushAsync I used

Navigation.PushModalAsync(new NavigationPage(new RegisterPet()));

and also OnAppearing of RegisterPet page I added SetHasNavigationBar

protected override void OnAppearing()
        {
            InitializeSettings();
            NavigationPage.SetHasNavigationBar(this, false);

            base.OnAppearing();
        }
like image 138
Eldlabs Avatar answered Sep 28 '22 01:09

Eldlabs