You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

MAUI Shell单个Tab顶部导航栏隐藏失败求助

MAUI Shell组件隐藏顶部导航栏失败求助

问题说明

尝试在MAUI的Shell组件中隐藏指定Tab的顶部导航栏,但始终无法完全实现效果。曾参考旧教程但无效,目前仅能移除导航栏的标题,导航栏本身仍保留显示。已尝试在Tab、ShellContent以及对应ContentPage上添加Shell.NavBarIsVisible="False"属性,均未解决问题。

当前代码

XAML(AppShell.xaml)

<Shell
    x:Class="Smogon_MAUIapp.AppShell"
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:local="clr-namespace:Smogon_MAUIapp"
    Shell.FlyoutBehavior="Disabled">


    <!--Main Page-->
    <TabBar>

        <Tab Icon="Resources/navbar/smogon.png" Shell.NavBarIsVisible="False" >
            <ShellContent
                Shell.NavBarIsVisible="False"
                NavigationPage.HasNavigationBar="False"
                ContentTemplate="{DataTemplate local:Pages.MainPage}" 
                Route="MainPage">
            </ShellContent>
            <ShellContent
                Shell.NavBarIsVisible="False"
                NavigationPage.HasNavigationBar="False"
                ContentTemplate="{DataTemplate local:Pages.Forum}"
                Route="Forum"/>
            <ShellContent
                Shell.NavBarIsVisible="False"
                NavigationPage.HasNavigationBar="False"
                ContentTemplate="{DataTemplate local:Pages.SubForum}"
                Route="SubForum"/>
            <ShellContent
                Shell.NavBarIsVisible="False"
                NavigationPage.HasNavigationBar="False"
                ContentTemplate="{DataTemplate local:Pages.Thread}"
                Route="Thread"/>
        </Tab>

        <Tab Icon="Resources/Images/search.png" Shell.NavBarIsVisible="False">
            <ShellContent
                ContentTemplate="{DataTemplate local:Pages.Search}" 
                Route="Search">
            </ShellContent>
        </Tab>

        <Tab Icon="Resources/Images/snorlax.png" Shell.NavBarIsVisible="False">
            <ShellContent
                ContentTemplate="{DataTemplate local:Pages.Profile}" 
                Route="Profile" />
        </Tab>

        <Tab Icon="Resources/Images/showdown.png" Shell.NavBarIsVisible="False">
            <ShellContent
                ContentTemplate="{DataTemplate local:Pages.Showdown}" 
                Route="Showdown" />
        </Tab>

    </TabBar>

</Shell>

C#后台代码(AppShell.xaml.cs)

public partial class AppShell : Shell
{
    public AppShell()
    {
        Routing.RegisterRoute("Home", typeof(MainPage));
        Routing.RegisterRoute("Forum", typeof(Forum));
        Routing.RegisterRoute("SubForum", typeof(SubForum));
        Routing.RegisterRoute("Thread", typeof(Smogon_MAUIapp.Pages.Thread));
        Routing.RegisterRoute("Search", typeof(Search));
        Routing.RegisterRoute("Profile", typeof(Profile));
        Routing.RegisterRoute("ShowDown", typeof(Showdown));

        InitializeComponent();
    }
}

当前状态

仅能移除导航栏标题,但导航栏主体仍存在,实际效果与预期不符。已在对应ContentPage中添加Shell.NavBarIsVisible="False"属性,问题依旧存在,寻求有效解决方法。


内容的提问来源于stack exchange,提问作者OzZzL

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.03 06:56:54