How to remove the Xamarin.Forms Navigation Bar?
Asked Answered
G

5

18

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.

Genous answered 29/9, 2014 at 11:39 Comment(1)
NavigationPage.HasNavigationBar="False" in XAML inline with the ContentPage tag.Steffy
C
44

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!

Catlike answered 29/9, 2014 at 12:14 Comment(0)
D
4

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

Diadromous answered 24/9, 2015 at 10:43 Comment(1)
Link is not working, and how can I change the icon of the ActionBar ?Vermillion
M
1

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

NavigationPage.SetHasBackButton(this, false);
Monarski answered 1/3, 2017 at 11:59 Comment(0)
T
0

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>
Tallie answered 5/9, 2018 at 15:4 Comment(0)
A
0

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>
Alrzc answered 26/8, 2019 at 4:37 Comment(1)
Could you explain why your solution solves the problem? There ist the HasNavigationBar='false' which has been mentioned in other solutionsLoeb

© 2022 - 2024 — McMap. All rights reserved.