我有一個使用 Shell 的 Xamarin Forms 應用程式,并且該應用程式的主頁恰好在 Shell 中定義了選項卡——見下文:
<FlyoutItem Title="Home">
<FlyoutItem.Icon>
<FontImageSource
FontFamily="MISHRP"
Glyph="{StaticResource HomeIcon}"
Color="White" />
</FlyoutItem.Icon>
<Tab Title="My Feed">
<ShellContent Route="MyFeed" ContentTemplate="{DataTemplate views:MyFeedFeed}"/>
</Tab>
<Tab Title="Card">
<ShellContent Route="PersonalCard" ContentTemplate="{DataTemplate views:PersonalCard}"/>
</Tab>
<Tab Title="Cart">
<ShellContent Route="Cart" ContentTemplate="{DataTemplate views:Cart}"/>
</Tab>
</FlyoutItem>
在 的OnStart()方法中App.xaml.cs,我檢查用戶是否經過身份驗證,如果沒有,我將用戶發送到Login具有以下代碼的單獨頁面:
protected override async void OnStart()
{
// Check to see if token has expired or missing
var tokenExpiration = await SecureStorage.GetAsync("token_expiration");
if(tokenExpiration == null)
await Shell.Current.GoToAsync(nameof(LoginPage));
// Some more logic here...
}
這很好,但是當我進入Login頁面時,我看到了 Shell 中定義的選項卡。
我已經Shell.NavBarIsVisible="False"在Login頁面上使用了成功隱藏導航欄但不是選項卡的頁面。
如何確保Login頁面上不顯示任何選項卡?
uj5u.com熱心網友回復:
我所要做的就是添加Shell.TabBarIsVisible="False"到LoginXAML。見下文:
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MyApp.Views.LoginPage"
Shell.NavBarIsVisible="False"
Shell.TabBarIsVisible="False">
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/459776.html
