我在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();
}
答案 0 :(得分:1)
您将必须进行以下更改:-
您的重定向应为:-
await Shell.Current.GoToAsync("//main");
您的App Shell应该有这个:-
<TabBar Route="main">
...
</TabBar>
希望这会有所帮助。
答案 1 :(得分:1)
从重定向await App.Current.MainPage.Navigation.PushModalAsync(new AppShell());
开始,我认为您有另一个Shell应用程序仅用于登录。
尝试await App.Current.MainPage = new AppShell();
将Shell初始化为您的主页。
希望这会有所帮助;)