I'm facing an issue with my back buttons in my .Net Maui app using shell in my case i have 3 pages for authentication AuthHome where there is a Login button when the user click on her he will be navigated to the login page than after he login he is redirected to the main page where he will find a start button when he click on her he will go to another page category containing a list view so the problem comes here because when i select an item the navigation goes well and I'm redirecting to the Subjects and when i click on back button it works but when i go for another page from the subjects page the navigation works but the backbutton is not working anymore same problem if I continue navigating to the next page the backbutton is not working so the problem start when i'm in the subjects page i can't go back to the previous page and even i go from the subject page to the next one the problem persist and the backbutton does not work also So this is my AppShell.xaml code :
<Shell
x:Class="AtomApprentissageMaui.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:views="clr-namespace:AtomApprentissageMaui.Views"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:AtomApprentissageMaui"
xmlns:custom="clr-namespace:AtomApprentissageMaui.Controls"
Shell.FlyoutHeaderTemplate="{DataTemplate custom:FlyoutHeader}"
Shell.FlyoutBehavior="Flyout">
<ShellContent Title="CheckState" ContentTemplate="{DataTemplate views:CheckState}" Route="CheckState" FlyoutItemIsVisible="False"/>
<ShellContent Title="AuthHome" Shell.TabBarIsVisible="False" ContentTemplate="{DataTemplate views:AuthHome}" Route="AuthHome" FlyoutItemIsVisible="False"/>
<ShellContent Title="AuthLogin" Shell.TabBarIsVisible="False" ContentTemplate="{DataTemplate views:AuthLogin}" Route="AuthLogin" FlyoutItemIsVisible="False"/>
<ShellContent Title="AuthSignUp" Shell.TabBarIsVisible="False" ContentTemplate="{DataTemplate views:AuthSignUp}" Route="AuthSignUp" FlyoutItemIsVisible="False"/>
<FlyoutItem FlyoutDisplayOptions="AsMultipleItems">
<ShellContent Title="Home" Shell.TabBarIsVisible="False" ContentTemplate="{DataTemplate local:MainPage}" Route="MainPage" FlyoutItemIsVisible="False" Icon="home.svg"/>
<ShellContent Title="Domains" ContentTemplate="{DataTemplate views:DomainHome}" Route="DomainHome" Icon="quiz.png"/>
<ShellContent Title="Settings" ContentTemplate="{DataTemplate views:Settings}" Route="Settings" Icon="settings.svg"/>
</FlyoutItem>
<Shell.FlyoutFooter>
<VerticalStackLayout Padding="10">
<Label Text="ATOM APPRENTISSAGE" HorizontalTextAlignment="Center" FontSize="18"></Label>
</VerticalStackLayout>
</Shell.FlyoutFooter>
<Shell.ItemTemplate>
<DataTemplate>
<Grid ColumnDefinitions="35,*" RowDefinitions="7,Auto,7,1" ColumnSpacing="10">
<Image Grid.Row="1" Grid.Column="0" Source="{Binding Icon}"></Image>
<Label Grid.Row="1" VerticalTextAlignment="Center" Grid.Column="1" FontAttributes="Bold" Padding="20,20,20,20" Text="{Binding Title}"/>
<BoxView Grid.Row="3" Color="LightSkyBlue" Grid.Column="0" Grid.ColumnSpan="2"></BoxView>
</Grid>
</DataTemplate>
</Shell.ItemTemplate>
</Shell>
This is my AppShell.cs also :
public AppShell()
{
InitializeComponent();
Routing.RegisterRoute(nameof(CheckState), typeof(CheckState));
Routing.RegisterRoute(nameof(AuthHome), typeof(AuthHome));
Routing.RegisterRoute(nameof(AuthLogin), typeof(AuthLogin));
Routing.RegisterRoute(nameof(AuthSignUp), typeof(AuthSignUp));
Routing.RegisterRoute(nameof(AuthForgot), typeof(AuthForgot));
Routing.RegisterRoute(nameof(MainPage), typeof(MainPage));
Routing.RegisterRoute(nameof(DomainHome), typeof(DomainHome));
Routing.RegisterRoute(nameof(MatiereHome), typeof(MatiereHome));
Routing.RegisterRoute(nameof(QuizHome), typeof(QuizHome));
Routing.RegisterRoute(nameof(QuizHomeDetails), typeof(QuizHomeDetails));
Routing.RegisterRoute(nameof(LoadingQuiz), typeof(LoadingQuiz));
Routing.RegisterRoute(nameof(QuizDisplay), typeof(QuizDisplay));
Routing.RegisterRoute(nameof(SubjectDetails), typeof(SubjectDetails));
Routing.RegisterRoute(nameof(CoursesHome),typeof(CoursesHome));
Routing.RegisterRoute(nameof(QuizSummary), typeof(QuizSummary));
Routing.RegisterRoute(nameof(QuizReview), typeof(QuizReview));
Routing.RegisterRoute(nameof(UserProfile), typeof(UserProfile));
Routing.RegisterRoute(nameof(Settings),typeof(Settings));
}
}
And finally these are the navigation methods : navigation from login page to Main Page :
[RelayCommand]
public async Task GoToHome()
{
await Shell.Current.GoToAsync($"//{nameof(MainPage)}");
}
navigation from home to category
[RelayCommand]
public async Task GotoDomains()
{
await Shell.Current.GoToAsync($"//{nameof(DomainHome)}");
}
and the navigation from domain to subjets :
[RelayCommand]
async Task GoToMatiereHomeAsync(DomainVM domainvm)
{
var parameters = Helpers.Helpers.CreateParameterUrl(domainvm, nameof(DomainsVM));
await Shell.Current.GoToAsync(Helpers.Helpers.ConvertToUrl(nameof(MatiereHome), parameters));
}