3
votes

I need hide navigation bar in xamarin forms 3.0.

I try this, but dont work: Hide Navigation Bar on MasterDetailPage

I want hide navigation bar for create a custom bar, also I need a way to open menu. Thanks.

App.xaml.cs

public partial class App : Application
{
    public App ()
    {
        InitializeComponent();

        MainPage = new MainPage();
    }
...

MainPage.xaml.cs

public partial class MainPage : MasterDetailPage
{
    public List<MasterPageItem> menuList { get; set; }
    public MainPage()
    {
        InitializeComponent();

        menuList = new List<MasterPageItem>();

        menuList.Add(new MasterPageItem() { Title = "Home", Icon = "home.png", TargetType = typeof(HomePage) });
        menuList.Add(new MasterPageItem() { Title = "Settings", Icon = "setting.png", TargetType = typeof(SettingsPage) });
        menuList.Add(new MasterPageItem() { Title = "Help", Icon = "help.png", TargetType = typeof(HelpPage) });

        navigationDrawerList.ItemsSource = menuList;

        var navPage = new NavigationPage((Page)Activator.CreateInstance(typeof(HomePage)));

        //I try this:
        NavigationPage.SetHasNavigationBar(navPage, false);
        NavigationPage.SetHasBackButton(navPage, false);

        Detail = navPage;
    }
...

MainPage.xaml

<?xml version="1.0" encoding="utf-8" ?>
<MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:App3"
             x:Class="App3.MainPage">

    <MasterDetailPage.Master>
        <ContentPage Title="Menu">
            <Grid BackgroundColor="Transparent">
                <StackLayout Grid.Row="1" Spacing="15">
                   ...
                </StackLayout>
            </Grid>
        </ContentPage>
    </MasterDetailPage.Master>

    <MasterDetailPage.Detail>
        <NavigationPage>

        </NavigationPage>
    </MasterDetailPage.Detail>
</MasterDetailPage>

Source repo: https://github.com/uiahhh/stackoverflow/tree/master/HideNavBar

I want remove this navbar in red circle: enter image description here

2
You should put relevant code in your question here on StackOverflow.Cheesebaron
@Cheesebaron I put the code and screen. :)Ricardo Carvalho

2 Answers

4
votes

On the detail page you have to remove the navigation bar with NavigationPage.SetHasNavigationBar(this, false); in the constructor right after InitializeComponent()

public partial class MyPage : NavigationPage
{
    public MyPage()
    {
        InitializeComponent();
        NavigationPage.SetHasNavigationBar(this, false);
    }
}
0
votes

In addition to Pedro's answer, you can also hide the navigation bar in your .xaml file. For example:

<ContentPage NavigationPage.HasNavigationBar="False">
    ...
</ContentPage>

Note: This works in Xamarin 4.0 but I haven't tested it in 3.0.