I have a iOS/Android .NET MAUI Shell app with Tabs where users can login.
I want to reset all tabs to the root element if a user logins in or out of my app, but I can't find a way to do it.
Is there a way in .NET MAUI Shell to retrieve the navigation stack of all tabs, so I can pop all pages?
Or any other idea how to reset all Tabs to the root page?
One way to reset each Tab's navigation stack individually is to call
PopToRootAsync()
on each. For this you need to give each Tab a name:Then call
PopToRootAsync()
on each navigation stack in the code-behind of your AppShell:This can be simplified if you give your TabBar an
x:Name
and then iterate through theItems
and callPopToRootAsync()
on each:Alternatively, you can also reset the
MainPage
to a new instance ofAppShell
in your App.xaml.cs:This is a common scenario when login pages are not part of the Shell hierarchy, but should also work in your case.