shell 如何在.NET MAUI中的特定页面上创建选项卡?

nqwrtyyt  于 2022-11-16  发布在  Shell
关注(0)|答案(2)|浏览(196)

我想为一个特定的页面制作标签,但是用AppShell我可以为每个页面都做这个。我只想在一个页面上制作标签,而不是其他页面。

2wnc66cl

2wnc66cl1#

如果你想在第一个页面之后显示你的标签页,你只需要导航到包含标签页的AppShell。例如,在一个有LoginPage和标签页的应用中,你可以这样做。

应用程序示例:

App.Current.MainPage = LoginPage;

应用程序 shell .xaml

<ShellContent
    Title="Home"
    ContentTemplate="{DataTemplate vm:HomePage}"
    />

然后,只需使用Shell导航导航到HomePage(选项卡页)。

App.Current.MainPage = new AppShell();
slsn1g29

slsn1g292#

您可以将MainPage设置为NavigationPage,然后导航到特定的Tabbedpage

应用程序.xaml.cs

public partial class App : Application
{
    public App()
    {
        InitializeComponent();
        MainPage = new NavigationPage(new MainPage());
    }
}

在您的主页中,您可以导航到如下所示的特定标签页:

await Navigation.PushAsync(new MyTabbedPage());

相关问题