Alan2
Alan2

Reputation: 24572

How can I set Shell.NavBarIsVisible="false" for a ContentPage in C#?

Here's the XAML I have:

<?xml version="1.0" encoding="UTF-8"?>
<ContentPage
    Shell.NavBarIsVisible="false"
    xmlns ="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    x:Class="Test.ABC" >

I am trying to recreate this in C# but coming up with a problem as none of these methods work:

namespace Test
{

    public partial class ABC : ContentPage
    {
        Shell.NavBarIsVisible = false;

        public ABC()
        {
            Shell.SetNavBarIsVisible = false;
            Shell.NavBarIsVisibleProperty = false;

Does anyone have any idea how I can do this in a C# implementation without the XAML file.

Upvotes: 1

Views: 2591

Answers (1)

Lucas Zhang
Lucas Zhang

Reputation: 18861

You need to invoke them in Method OnAppearing

in ContentPage

protected override void OnAppearing()
{
   base.OnAppearing();
   Shell.SetTabBarIsVisible(this, false);
   Shell.SetNavBarIsVisible(this, false);
}

Note : If you only want to hide Tabbar and NavigationBar in a specific ContentPage , don't forget to display them when leaving the page

protected override void OnDisappearing()
 {
   base.OnDisappearing();
   Shell.SetTabBarIsVisible(this, true);
   Shell.SetNavBarIsVisible(this, true);
}

Upvotes: 8

Related Questions