lkujala
lkujala

Reputation: 203

is Maui Shell.NavBarIsVisible supposed to be a global setting for all pages

In a MAUI contentpage.xaml you can set Shell.NavBarIsVisible="false" as per the code below. (just showing the key parts of the pages and appshell xaml).

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage 
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    x:Class="MAUI.DetailPage"
    
    Shell.NavBarIsVisible="True"
    Shell.TabBarIsVisible="False"
    Shell.FlyoutBehavior="Disabled"
    Title="Detail Page"
    >
...


<?xml version="1.0" encoding="UTF-8" ?>
<Shell
    x:Class="MAUI.AppShell"
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:local="clr-namespace:MAUI"
    >
    <!-- home landing page -->
    <ShellItem
        Title="Home"
        Route="Home">
        <ShellContent
            Title="Home"
            ContentTemplate="{DataTemplate local:HomePage}"
            Route="HomePage"
                />
    </ShellItem>
   <FlyoutItem
    FlyoutDisplayOptions="AsMultipleItems">
        <Tab Title="Data">
            <ShellContent
            Title="List"
            ContentTemplate="{DataTemplate local:ListPage}"
            Route="ListPage" />
        </Tab>
        <Tab Title="About" >
            <ShellContent
            Title="About"
            ContentTemplate="{DataTemplate local:AboutPage}"
            Route="AboutPage" />
        </Tab>
   </FlyoutItem>
</Shell>

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="MAUI.HomePage"
   Title="Home Page"
   >
...

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage 
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    x:Class="MAUI.ListPage"
    Title="List Page"
    >
...

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage 
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    x:Class="MAUI.AboutPage"
    Title="About">
...

Navigation Sequence

  1. open app to Home Page
  2. use flyout to navigate to List Page
  3. List Page (Flyout shown, NavBar shown, TabBar shown)
  4. navigate to Detail page
  5. Detail page (Flyout hidden, NavBar shown, TabBar shown - even though tabbar, flyout have been turn off in xaml)
  6. from tabbar pick About page
  7. About page (Flyout shown, NavBar shown, TabBar shown)
  8. from About page pick the List page from tabbar
  9. the Detail page is shown (not the selected List page, but this is actually correct), (Flyout hidden, NavBar shown, TabBar hidden as per the xaml settings)
  10. click on Detail page back button
  11. the List page is shown (Flyout shown, NavBar shown, TabBar hidden ... TabBar should be shown)

Two basic problems:

If I skip steps 6, 7, 8; I can navigate back and forth between Home page, List Page, and Detail page and the Detail page will always show the flyout, navbar, and tabbar.

After step 11, if I go back to Home Page then everything goes back to step 1 again.

Question: is a Shell setting, set in a content page xaml, global to all application pages, or am I just seeing a bug? is there a different way of showing/hiding Flyout, TabBar, NavBar on a per page basis?

Upvotes: 1

Views: 479

Answers (1)

Jessie Zhang -MSFT
Jessie Zhang -MSFT

Reputation: 13853

step 5 expecting tabbar to be hidden.

You can try to push pages to the navigation stack when you click ListPage and navigate to DetailPage.

For example:

 await Navigation.PushAsync(new DetailsPage());

For more information, check document: NavigationPage.

Upvotes: 0

Related Questions