1

My Xamarin Shell application has a flyout defined as follow:

<?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:local="..."
       xmlns:viewModels="..."
       x:Class="...">

       <FlyoutItem x:Name="A1" FlyoutDisplayOptions="AsMultipleItems">
          <ShellContent x:Name="a1">
             <local:Homepage/>
          </ShellContent>
       </FlyoutItem>

       <FlyoutItem FlyoutDisplayOptions="AsMultipleItems">
          <ShellContent Route="Settings" ContentTemplate="..." />
       </FlyoutItem>

       <FlyoutItem x:Name="LoginFlyoutItem" FlyoutDisplayOptions="AsMultipleItems">
          <ShellContent x:Name="Login" Route="Login" ContentTemplate="..." />
       </FlyoutItem>
    
</Shell>

I want the Login page to perform a navigation to the a1 page after the user logs in with an

await Shell.Current.GoToAsync(nameof(Homepage));

The issue is that the a1 page shows the back button on the top left corner when opened, but I want it to show the normal hamburger icon to open the flyout. I would expect the back button when using the PushAsync() method, but not using the GoToAsync() one. I don’t want the a1 page to be considered a “child” of the login page, but I simply want the view model to navigate to the a1 page. How can I accomplish that?

Cfun
  • 8,442
  • 4
  • 30
  • 62
Pine Code
  • 2,466
  • 3
  • 18
  • 43
  • Assuming you don't want the user to navigate again to login page. Have you tried to set IsVisible property to false on your Login page upon user logging? If your app structure allows it this https://stackoverflow.com/q/65186262 could be helpful. – Cfun Dec 12 '20 at 21:23
  • I don't want to hide the login page, i just want a1 not to be treated like a child of the login page. – Pine Code Dec 12 '20 at 22:10

1 Answers1

3

Add // to switch to a different navigation stack instead of becoming a child page:

await Shell.Current.GoToAsync($"//{nameof(Homepage)}");
Cfun
  • 8,442
  • 4
  • 30
  • 62
Shaw
  • 907
  • 1
  • 8
  • 20
  • 2
    I was setting a global route with `Routing.RegisterRoute(nameof(Homepage), typeof(Homepage))`, and that caused a conflict. I removed the global route and now it works. – Pine Code Dec 13 '20 at 09:26