Search code examples
navigationxamarin.formsprismtabbedpage

Navigate using TabbedPage w Prism.Forms


How would you implement tabbed navigation using prism.forms (latest) deep linking?

I.E populate a TabbedPage with your prism pages and navigate using Prism when the used clicks a tab.

ANSWER:
The great Brian of course provided an answer. To clearify the implementation for those looking to do this.

My main navigation is a NavigationPage (which of course can contain my main toolbar icons) where I then navigate to the content page in question:

navigationService.NavigateAsync("MyNavigationPage/MyMainPage");

So what I've done is added a Prism page of type TabbedPage. In this I can simply place other Prism pages as children:

<TabbedPage x:Class="MyApp.MyTabbedPage">
    <TabbedPage.Children>
        <MyFirstPrismPage Title="tab 1">
        <MySecondPrismPage Title="tab 2">
    </TabbedPage.Children>
</TabbedPage>

This allowed me to navigate to "MyTabbedPage/MySecondPrismPage" and both pages were able to resolve their viewmodels!


Solution

  • Clicking a tab is not a navigation action. That is a tab selection changed action. Assuming you have populated your TabbedPage with your pages, you can navigate and select a tab by calling NavigateAsync("MytabbedPage/TabToSelect")