user3509981
user3509981

Reputation: 297

How to remove the Xamarin.Forms Navigation Bar?

Is there any way to remove the Navigation Bar from Xamarin.Forms - Portable (xaml) in Android?

I want to remove the "less than sign" ('<') and the application icon which appears above the content page of the Xamarin.Forms xaml.

Upvotes: 18

Views: 13112

Answers (5)

Ravinder Jangra
Ravinder Jangra

Reputation: 11

It's called the "back button" and it is available in the action bar. you can remove it using:

NavigationPage.SetHasBackButton(this, false);

Upvotes: 1

Chetan Rawat
Chetan Rawat

Reputation: 588

The Best way to achieve this from xml page

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
x:Class="ICLDC.Digital.General.Pages.AboutApp.AboutApplication"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core"
xmlns:local="clr-namespace:ICLDC.Digital.General.Pages.Generic"
xmlns:translate="clr-namespace:ICLDC.Digital.General.Helpers"
ios:Page.UseSafeArea="True"
NavigationPage.HasNavigationBar="False">
<ContentPage.Content>
    <StackLayout
        BackgroundColor="White"
        HorizontalOptions="FillAndExpand"
        Spacing="0"
        VerticalOptions="FillAndExpand"/>   
</ContentPage.Content>
</ContentPage>

Upvotes: 0

Moses Nero
Moses Nero

Reputation: 11

The easiest way to achieve this is to add NavigationPage.HasNavigationBar = "false" in your ContentPage

 <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="SterlingSwitch.Pages.Page1"
             NavigationPage.HasNavigationBar="False">
    <ContentPage.Content>
        <StackLayout>
            <Label Text="Welcome to Xamarin.Forms!"
                VerticalOptions="CenterAndExpand" 
                HorizontalOptions="CenterAndExpand" />
        </StackLayout>
    </ContentPage.Content>
</ContentPage>

Upvotes: 0

Yksh
Yksh

Reputation: 3306

NavigationPage.SetHasNavigationBar(this, false);

The above mentioned is not the good solution.

By using this code it disable the NavigationBar present in the page.

We can achieve the real solution only by creating a NavigationRenderer for NavigationPage for Android.

void RemoveAppIconFromActionBar()
{
    var actionBar = ((Activity)Context).ActionBar;
    actionBar.SetIcon (new ColorDrawable (Color.Transparent.ToAndroid ()));
}

Refer the Github for the complete code snippet : https://gist.github.com/Vaikesh/f86d1968c8166519f102#file-customnavigationrenderer-cs

Upvotes: 4

Nirav Mehta
Nirav Mehta

Reputation: 7063

You can remove navigation bar from Xaml using Xamarin.Forms using below code.

NavigationPage.SetHasNavigationBar (this, false);

Where this stands for current page / form instance.

Hope this helps!

Upvotes: 44

Related Questions