Xamarin Navigating from a TabbedPage app - xamarin

I've been tinkering with Xamarin forms and I have run into a bit of a road block. I have an app whose rootPage is a TabbedPage. I programmatically add three child Contentpages to this page. All this works fine. However, these pages open up other pages which may or may not open other pages etc.
I have tried to use ContentPage for the child pages and pass the rootpage Navigation property into them and use that to call Navigation.PushAsync I have also tried to make the pages navigation pages and then call Navigation.PushAsync on their own property: this throws some unhandled exception
Can anyone please help!

The root of each tab in your TabbedPage should be a single NavigationPage, which wraps a ContentPage. From that ContentPage you navigate to other pages by using the Navigation property of the page.

Related

PRISM Library: Transition animations not working when using absolute navigation in the NavigateAsync call

Basically I would like some help with navigation in the prism library. I have been using NavigateAsync method to navigate through pages in my xamarin forms app. No issues with it.
I have been navigating from PageA -> PageB using NavigateAsync("PageB") and I am getting an animation while navigating to PageB. Due to some requirements, I need to reset the navigation page stack when navigating to PageB, so I have decided to use absolute path in the navigation with NavigateAsync("/PageB").
The stack gets clear as expected, but unfortunately, the animation while navigating to PageB is gone, and the page just show up without any animation.
Does anyone knows how to activate the animation when using absolute path in the navigation in PRISM?

Prism Xamarin Forms ToolbarItem appearing twice

I am using Prism for Xamarin Forms application development.
May be because I am new to both Prism and Xamarin Froms because of which I am facing a basic issue with the navigation.
Let me start with the details of my implementation and then the issue at hand.
I have a MasterDetail Page (named Home) which is my main page.
There are a few menu items in the Master Page. One of them is Partner.
On Click of Partner menu item, NavigationService.NavigateAsync("Navigation/Partner") method is called. Where "NavigationService" is of type "INavigationService".
This opens a page called "Partner" which is a tabbed page (TabbedPage). The first tab is a contentpage called "PartnerAll".
PartnerAll page contains a listview. On click of a list view item, a new page is opened "PartnerDetails" by calling NavigationService.NavigateAsync("Navigation/PartnerDetails", parameters, false, true);
On PartnerDetails page, I have added a toolbaritem called "Cancel".
Issue: When "PartnerDetails" page opens up, "Cancel" item shows up twice, as shown in the screenshot:
screenshot of partner details page with two cancel buttons
Where is it I am going wrong. What should I do to make it work?
Please assist.
Best regards, Ankur Jain
You’re pushing two NavigationPage’s onto the Navigation Stack. This would result in two Navigation bars. You can see in your screenshot you have both a back and a hamburger menu icon.
You should just pass in the identifier string for your destination page, instead of pushing another instance of the NavigationPage onto the stack
do it like so NavigationService.NavigateAsync(PartnerDetails);

Xamarin Forms Prism child Tabbed page OnNavigatingTo not firing?

When I navigate within tabbed pages, OnNavigatingTo does not fire. There are several different threads around this subject but I don't see that there is a solution? My environment is a Main Page (login) > MasterDetails Page > Tabbed Page > Child Content Page.
_navigationService.NavigateAsync("MasterDetail/Navigation/DashboardPage/Child1TabPage");
<TabbedPage.Children>
<views:Child1TabPage/>
<views:Child2TabPage/>
</TabbedPage.Children>
I've tried using an additional navigation page either in the MainPage, or on the Dashboard page with useModalNavigation on or off but that doesn't work either. Like so.
navigationService.NavigateAsync("MasterDetail/Navigation/DashboardPage/NavigationTabbed/Child1TabPage", null, false, true);
or on the tabb DashboardPage like so
navigationService.NavigateAsync("NavigationTabbed/Child1TabPage", null, false, true);
Any ideas?
There is currently no mechanism built into Prism for Xamarin Forms that would call INavigationAware on Children of any MultiPage such as the TabbedPage or CarouselPage. This is a planned enhancement for Prism for Xamarin Forms 6.3 and should be available in Preview 3. You can follow the issue here.

Xamarin Forms NavigationPage showing multiple back buttons

I have several navigation pages that go several levels deep. Each time the user navigates to another page, an additional Back button is added to the top.
Navigation.PushAsync(new NavigationPage(new SettingsPage()));
Do I have to manually turn off the navigation bar prior to Pushing the new page or is there some type of setting for this?
Thanks.
Like Sushi mentioned in the comment, you're already in navigation page, you do not have to push a new NavigationPage every time.
Just use:
Navigation.PushAsync(new SettingsPage());
You can read more about navigation in Xamarin.Forms here: https://developer.xamarin.com/guides/xamarin-forms/user-interface/navigation/hierarchical/

Create custom Tabbar in Xamarin Forms using NaviagtionPages & Buttons added inside a ContentPage

I want to create custom Tabbar in Xamarin Forms using NaviagtionPages & Buttons added inside a ContentPage.
I cannot use the default Tabbed Page because the UI shows up differently for Android and iOS with it (tabbar at top on android vs tabbar at bottom for iOS).
Hence, I was creating a common component using Xamarin forms.
I have created a similar custom tabbar in iOS (by adding Navigation controllers as child controllers along with buttons in a View controller).
So far I have added Buttons and ContentPages(by ContentPage.Content) inside a ContentPage. I toggle the visibility of the content pages on tapped events of the buttons.
But I want to replace the ContentPages by NavigationPages so that each tab(button) can have its own stack of ContentPages.
Unfortunately, I cannot figure out how to add NavigationPage inside a content view to make this work.

Resources