In my shell, I have defined a route "main". Nested underneath, I have defined a tabbar with the route "tabs". I want to navigate from my homepage to this tab page using a button. The tabpage should have a back button to get back to the homepage again (aka, I want to do relative navigation.).
When I try to do the navigation using this line of code: await Shell.Current.GoToAsync("tabs");
... I get this error: "System.ArgumentException: 'unable to figure out route for: tabs (Parameter 'uri')'"
Below is my AppShell.xaml:
<?xml version="1.0" encoding="UTF-8" ?>
<Shell
x:Class="MauiTabShell.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:MauiTabShell"
xmlns:pages="clr-namespace:MauiTabShell.Pages"
Shell.FlyoutBehavior="Disabled">
<ShellContent
Title="Home"
ContentTemplate="{DataTemplate local:MainPage}"
Route="main">
<TabBar Route="tabs">
<ShellContent ContentTemplate="{DataTemplate pages:PageOne}" />
<ShellContent ContentTemplate="{DataTemplate pages:PageTwo}" />
<ShellContent ContentTemplate="{DataTemplate pages:PageThree}" />
</TabBar>
</ShellContent>
</Shell>
Reproduction: https://github.com/BurkusCat/MauiShellTabNavRepro
- I have tried having the tabbar at the same level as the homepage and doing absolute navigation (
"//tabs"
) which works, but doesn't give me a back button - I have tried registering a
TabbedPage
in "AppShell.xaml.cs`, but TabbedPages don't work with Shell according to Maui documentation
Routing.RegisterRoute("tabs", typeof(MyTabbedPage));
- I've tried creating a "TabBar" xaml and xaml.cs file in a similar way to the way you would create a ContentPage or TabbedPage. This didn't work. I tried doing this in pure CSharp too.
- I've tried various routes such as (
"//home/tabs"
) to get the navigation to work but no joy.
I feel like this should be the most simple task but I have had no success so far and have not been able to find any good examples of this kind of navigation (the documentation and most tutorials start on a tabbar/flyout rather than trying to navigate from a homepage to a page with tabs).
Ultimately, my goal is to navigate from a ContentPage to a page with tabs. So I don't particularly care if that ends up being a TabBar or a tab page. I think I could probably skip shell for this one navigation, but then I'd lose all the dependency injection / parameter passing which would be bad.