mvvmnavigationmaui.net-maui.shell

.NET Maui - Reset Navigation Stack when clicking on the same Tab that is currently displayed


I want to implement very specific thing for TabBar in my maui shell app. User can now technically go in infinite loop of going in to details page on that one tab.

RootTabPage-> DetailsPage -> DetailsPage -> DetailsPage.... I want to make it possible to go back to the root with one click, so.. RootTabPage -> DetailsPage -> DetailsPage -> DetailsPage -> ClickOnTheSameTab -> RootTabPage.

I've found this code on stackoverflow: .NET Maui - Reset Navigation on TabBar Item Click

But it will remove stack when going to DIFFERENT tab, which is not what I want and it is UX issue. I also tried binding CurrentItem in TabBar but it doesn't trigger when going to the same tab i'm on.

So I want to implement the described behavior that is: If I'm on the same tab that I'm clicking on, remove whole stack on this tab. Back button must behave normally that is removing just one page from stack.


Solution

  • Unfortunately, clicking on active tab does not trigger tab changed event.