4
votes

(Using Prism 6.1.0-pre6 and XF 2.3.0.107)

Summary: Navigating to a ContentPage from a TabbedPage doesn't show the toolbar/actionbar.

I navigate to a TabbedPage (MainPage.xaml) from another page. This looks like this:

<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:Or.Console.Views"
             xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
             prism:ViewModelLocator.AutowireViewModel="True"
             x:Class="Or.Console.Views.MainPage">
  <local:APage/>
  <local:BPage/>
  <local:CPage/>
</TabbedPage>

And in the ViewModel for APage, I'm calling

_navigationService.NavigateAsync("DetailsPage");

The DetailsPage is just a ContentPage, and I would expect that it would show with the back button and action bar at the top, but it doesn't.

I'm guessing this is because Prism doesn't know about the tab child pages, only the TabbedPage itself.

I've tried registering the tab child pages with Prism, but this doesn't seem to work. Also tried wrapping each tab child in a NavigationPage, but this brings on some strange behavior with duplicate toolbars.

What's the right way to navigate from within tabbed content?

EDIT: In response to Brian Lagunas answer, I tried wrapping the TabbedPage in a NavigationPage, so when I navigate to it, I'm calling

 _navigationService.NavigateAsync("DeviceNavWrapper/MainPage");

But this gives an odd result: enter image description here

EDIT2: Solution in my case ended up that I needed to call NavigateAsync from APage with the useModalNavigation set to false. So now APage has this:

_navigationService.NavigateAsync("DetailsPage", null, false);
2
Thanks Erin, this solves my problemKhang Tran

2 Answers

5
votes

The only way to get a back button at the top is to have the page nested inside a NavigationPage. This is standard Xamarin.Forms behavior. So you have a couple of options. One would be to wrap your APage in a NavigationPage. Then when you call NavigateAsync("DetailsPage") from APageViewModel, it will work as you want.

EDIT: If you want to navigate to a completely different Page and replace the TabbedPage, then make sure the TabbedPaged is wrapped in a NavigationPage, and navigate from the TabbedPageViewModel.

1
votes

To eliminate duplicate Toolbar, I found out that settting

   NavigationPage.HasNavigationBar="False"

of the NavigationPage Wrapper easier