【发布时间】:2020-03-04 11:30:27
【问题描述】:
我有一个多页应用程序,其中有 preLogin 部分和 postLogin 部分。
为这两个部分制作 shell 模板的最佳方法是什么?
preLogin 页面在导航栏中没有后退按钮。我在 xaml 页面 NavigationPage.HasNavigationBar="false"(不是 AppShell.xaml,在我的页面 xaml 中)以及 NavigationPage.SetHasNavigationBar(this, false); 后面的代码中尝试过
示例 xaml 页面,不管我的 NavigationPage.HasBackButton="false"
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:customViewEntry="clr-namespace:App.CustomViews.Entries"
xmlns:header="clr-namespace:App.CustomViews.CustomHeaders"
mc:Ignorable="d"
x:Class="App.Views.Login.EnterEmailAndPasswordPage"
NavigationPage.HasBackButton="false"
BackgroundImageSource="Login_Screen_Green.png">
<ContentPage.Content>
<StackLayout>
<header:HeaderWithTopRightIcon ImageUri="greenIcon.png"/>
<StackLayout VerticalOptions="EndAndExpand" Padding="0,50">
<customViewEntry:EvEntry
Placeholder="Enter your email"/>
<customViewEntry:EvEntry
Placeholder="Enter your password"
IsPassword="True"/>
<Button
Text="LOGIN"
Margin="25,0"
CornerRadius="7"
BackgroundColor="{StaticResource DarkGrayColor}"
TextColor="White"
Command="{Binding OpenEmailVerificationPageCommand}"/>
<Label
Padding="0,25,0,0"
Text="Don't have an account?"
FontSize="Small"
Style="{StaticResource WhiteSmallLabelStyle}"
HorizontalOptions="Center"
VerticalOptions="Start"/>
<Label
Text="SIGN UP"
TextDecorations="Underline"
FontSize="Small"
Style="{StaticResource WhiteSmallBoldLabelStyle}">
<Label.GestureRecognizers>
<TapGestureRecognizer Command="{Binding SignUpClickCommand}"/>
</Label.GestureRecognizers>
</Label>
</StackLayout>
</StackLayout>
</ContentPage.Content>
</ContentPage>
我的 AppShell 看起来像:
<?xml version="1.0" encoding="UTF-8"?>
<Shell xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:views="clr-namespace:App.Views"
xmlns:loginViews="clr-namespace:App.Views.Login"
x:Class="App.AppShell"
FlyoutBehavior="Disabled">
<!--Styles and Resources-->
<Shell.Resources>
<ResourceDictionary>
...removed due simplicity...
</ResourceDictionary>
</Shell.Resources>
<ShellContent ContentTemplate="{DataTemplate loginViews:EnterEmailPage}"/>
</Shell>
所以,我的问题是
1. 如何在某些页面上动态隐藏后退按钮,在某些页面上不动态隐藏?对于导航我使用await Shell.Current.GoToAsync(route)
2.当用户离开应用程序时,我还需要重定向,并根据经过的时间再次输入,重定向到 preLogin 页面(登录)或让他直接到 postLogin(对应用程序的完全访问权限)所以我可能需要两个 AppShell 类,并将其称为不同的外壳 OnResume() ?
【问题讨论】:
标签: xamarin xamarin.forms