1

So I have a xamrain forms Shell app that is not showing its back button

I have the App.cs here showing you how the shell is linked in.

public partial class App : Application
{
     

    public App()
    {
        Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("removed for security");
        DevExpress.XamarinForms.Editors.Initializer.Init();
        DevExpress.XamarinForms.DataGrid.Initializer.Init();

        RaygunClient.Init("removed for security");
        RaygunClient.Current.EnableCrashReporting();
        InitializeComponent();
   //   MainPage = new NavigationPage(new LoginPage());
       MainPage = new AppShell();
    }
}

My App Shell

<?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="clr-namespace:THEHOCKEYLAB.Views"
   Title="THEHOCKEYLAB"
   x:Class="THEHOCKEYLAB.AppShell"
   FlyoutBehavior="Flyout"
   FlyoutHeaderBehavior="Fixed"
   BackgroundColor="#121212">
<!--
    The overall app visual hierarchy is defined here, along with navigation.

    https://learn.microsoft.com/xamarin/xamarin-forms/app-fundamentals/shell/
-->

<Shell.Resources>
    <ResourceDictionary>
        <Style x:Key="BaseStyle" TargetType="Element">
            <Setter Property="Shell.BackgroundColor" Value="{StaticResource Primary}" />
            <Setter Property="Shell.ForegroundColor" Value="White" />
             
            
            <Setter Property="Shell.DisabledColor" Value="#B4FFFFFF" />
            <Setter Property="Shell.UnselectedColor" Value="#95FFFFFF" />
            <Setter Property="Shell.TabBarBackgroundColor" Value="{StaticResource Primary}" />
            <Setter Property="Shell.TabBarForegroundColor" Value="White"/>
            <Setter Property="Shell.TabBarUnselectedColor" Value="#95FFFFFF"/>
            <Setter Property="Shell.TabBarTitleColor" Value="White"/>
        </Style>
        <Style TargetType="TabBar" BasedOn="{StaticResource BaseStyle}" />
        <Style TargetType="FlyoutItem" BasedOn="{StaticResource BaseStyle}" />
    </ResourceDictionary>
</Shell.Resources>
<Shell.FlyoutHeaderTemplate>
    <DataTemplate>
        <Grid BackgroundColor="{StaticResource Primary}" Padding="20">
            <Label Text="The Hockey Lab"
                  TextColor="White"
                  HorizontalTextAlignment="Center"
                  VerticalTextAlignment="Center" />
        </Grid>
    </DataTemplate>
</Shell.FlyoutHeaderTemplate>


<FlyoutItem Title="Checkin" Icon="cal.png">
    <ShellContent ContentTemplate="{DataTemplate local:CheckInPage}"/>
</FlyoutItem>
<FlyoutItem Title="Bike WorkOut Listings" Icon="bike.png">
    <ShellContent ContentTemplate="{DataTemplate local:BikePage}"/>
</FlyoutItem>
<FlyoutItem Title="Sessions Listings" Icon="time.png">
    <ShellContent ContentTemplate="{DataTemplate local:SessionPage}"/>
</FlyoutItem>
<FlyoutItem Title="Weights Lifting Listings" Icon="weights.png">
    <ShellContent ContentTemplate="{DataTemplate local:WeightLiftingPage}"/>
</FlyoutItem>
 

<MenuItem Text="Settings" IconImageSource="settings.png" Command="{Binding SettingsCommand}" />

<FlyoutItem Title="About" Icon="icon_about.png">
    <Tab Title="Home">
        <ShellContent Route="Home" ContentTemplate="{DataTemplate local:AdminMenuPage}" />
    </Tab>
    <Tab Title="Weight Lifting">
        <ShellContent Route="WeightLifting" ContentTemplate="{DataTemplate local:WeightLiftingPage}" />
    </Tab>
</FlyoutItem>
<FlyoutItem Title="Browse" Icon="icon_feed.png">
    <ShellContent Title="page_1" Route="ItemsPage" ContentTemplate="{DataTemplate local:AdminMenuPage}" />
</FlyoutItem>


<TabBar>
    <ShellContent Title="Home" Icon="icon_about.png"   ContentTemplate="{DataTemplate local:AdminMenuPage}" />
    <ShellContent Title="Settings" Icon="icon_feed.png" ContentTemplate="{DataTemplate local:SettingsPage}" />
</TabBar>

<!--
    If you would like to navigate to this content you can do so by calling
    await Shell.Current.GoToAsync("//LoginPage");
-->
<TabBar>
    <ShellContent Route="LoginPage" ContentTemplate="{DataTemplate local:LoginPage}" />
    <ShellContent Title="Settings" Icon="icon_feed.png" ContentTemplate="{DataTemplate local:SettingsPage}" />

</TabBar>


<!-- When the Flyout is visible this will be a menu item you can tie a click behaviour to  -->

enter image description here But for some reason, my back button is not showing at all. I am using xf forms version 5.0.0.2196

Also, how does one get a login route to work properly when using shell.

c-sharp-and-swiftui-devni
  • 3,743
  • 4
  • 39
  • 100
  • I am not sure what exactly you are looking to achieve but I guess these answers might be helpful https://stackoverflow.com/q/66173044/5228202 https://stackoverflow.com/q/65186262/5228202 – Cfun Dec 18 '21 at 21:36
  • As soon as I hit sessions a back button should be there to take me back to the main screen. – c-sharp-and-swiftui-devni Dec 18 '21 at 21:42
  • Shell does not show a back button, unless user navigates to a page that is NOT a child of `Shell` xaml. (I personally find that design decision weird, but that is how it is.) User is "free" to use the menu or tabs to go wherever they want, whenever they want. – ToolmakerSteve Dec 18 '21 at 21:43
  • 1
    See [my answer here](https://stackoverflow.com/a/70311375/199364), for a workaround. – ToolmakerSteve Dec 18 '21 at 21:46
  • *"how does one get a login route to work properly"* - what does that mean? Please describe precisely the desired behavior, show code you attempted, and what actually happened. P.S.: Its less confusing for future readers, if you only ask ONE question in each question. Please make a separate question for the "login route". With the description I suggest. You can include a link there back to this question. – ToolmakerSteve Dec 18 '21 at 21:51

0 Answers0