Reputation: 107
Only on the login
and notifications
pages I wish that the user could not return to the previous page. On all other pages the process can proceed normally.
So far, I've only been able to disable the button click action using BackButtonBehavior IsEnabled = "False"
.
NotificationsPage.xaml and LoginPage.xaml
<Shell.BackButtonBehavior>
<BackButtonBehavior IsEnabled="False"/>
</Shell.BackButtonBehavior>
TokenViewModel
await Shell.Current.GoToAsync($"{nameof(NotificacoesPage)}");
App.xaml.cs
await Shell.Current.GoToAsync($"{nameof(NotificacoesPage)}", false);
AppShell.xaml
<TabBar>
<Tab Icon="notificacao_icone.png"
Title="Notificações">
<ShellContent ContentTemplate="{DataTemplate local:NotificacoesPage}" />
</Tab>
<Tab Icon="configuracoes_icone.png"
Title="Configurações">
<ShellContent ContentTemplate="{DataTemplate local:ConfiguracoesPage}" />
</Tab>
</TabBar>
AppShell.xaml.cs
Routing.RegisterRoute(nameof(LoginPage), typeof(LoginPage));
Routing.RegisterRoute(nameof(TokenPage), typeof(TokenPage));
Routing.RegisterRoute(nameof(NotificacoesPage), typeof(NotificacoesPage));
Routing.RegisterRoute(nameof(NotificacaoDetalhePage), typeof(NotificacaoDetalhePage));
Routing.RegisterRoute(nameof(ConfiguracoesPage), typeof(ConfiguracoesPage));
Upvotes: 5
Views: 2690
Reputation: 15021
Here is a workaround.You could hide the whole navigationbar,then custom a NavigationBar with StackLayout to instead of it.
Something like:
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="ShellNewDemo.Views.ItemDetailPage"
Shell.NavBarIsVisible="False" //hide the navigationbar
>
<ContentPage.Content>
<StackLayout Orientation="Vertical">
<StackLayout Orientation="Horizontal">
//define your custom navigationbar
</StackLayout>
<StackLayout Orientation="Vertical">
//content
</StackLayout>
</StackLayout>
</ContentPage.Content>
</ContentPage>
Upvotes: 2