5

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>

Back arrow button visible in navigation bar

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));
8
  • After the user fills in the login fields and fills in the token field, he is directed to the notifications page (the one on the print). Through the lower menu he can access the settings page where he can delete his account (this will take him to the login page to fill in the fields again). Commented Feb 18, 2021 at 19:01
  • Both using gotoasync Commented Feb 18, 2021 at 19:57
  • Would modal navigation suit you?
    – Shaw
    Commented Feb 18, 2021 at 21:06
  • This is a known issue and it had been moved to the to do block.
    – Leo Zhu
    Commented Feb 19, 2021 at 2:51
  • @Shaw I will not be able to use modal navigation because I need to display the app's logo in Shell.TitleView. Commented Feb 19, 2021 at 11:35

1 Answer 1

2

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>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.