登录用户并导航回主页Shell



我在Xamarin表单应用程序中使用Shell,当我的用户成功注册时,我遇到了一个问题,他被重定向到主页,但是底部没有选项卡菜单,而如果我将他重定向到AppShell,页面是空白的。你有什么建议吗?

我的重定向

await App.Current.MainPage.Navigation.PushModalAsync(new AppShell());

我的AppShell

<TabBar >
<Tab  x:Name="HomePage" Icon="home.png" Title="{x:Static resources:AppResources.LabelHome}" >
<ShellContent ContentTemplate="{DataTemplate views:HomePage}"/>
</Tab>
<Tab  x:Name="Categories" Icon="collections.png " Title="{x:Static resources:AppResources.LabelCategory}">
<ShellContent ContentTemplate="{DataTemplate views:CategoriesPage}"/>
</Tab>
<Tab  x:Name="Add" Icon="add.png" Title="{x:Static resources:AppResources.LabelAddingPage}">
<ShellContent ContentTemplate="{DataTemplate views:AddingPage}"/>
</Tab>
<Tab  x:Name="Inbox" Icon="mail.png" Title="{x:Static resources:AppResources.LabelInbox}" >
<ShellContent ContentTemplate="{DataTemplate views:InboxPage}"/>
</Tab>
<Tab  x:Name="Profile" Icon="userg.png" Title="{x:Static resources:AppResources.LabelProfil}">
<ShellContent ContentTemplate="{DataTemplate views:UserProfilePage}"/>
</Tab>
</TabBar>

还有我的应用

public App()
{
InitializeComponent();

MainPage = new AppShell();
}

从重定向await App.Current.MainPage.Navigation.PushModalAsync(new AppShell());,我认为您有另一个Shell应用程序只用于登录。

尝试await App.Current.MainPage = new AppShell();将Shell初始化为您的mainPage。

希望这能有所帮助;(

您必须进行以下更改:-

  1. 您的重定向应该是:-

    await Shell.Current.GoToAsync("//main");
    
  2. 你的应用程序外壳应该有这个:-

    <TabBar Route="main">
    ...   
    </TabBar>
    

希望这能有所帮助。

最新更新