So I have a tab bar and some pages attached to it, and what I'm trying to do is navigate to a different page(not a tab bar page) by clicking a button which is present in one of these tab bar pages, on doing so that page is replacing the tab bar, how would I be able to navigate inside the tab bar itself, I checked a couple of threads and doing a PushAsync should do the trick but its not working
This is a snippet of my NavigateAsync Method
public async Task NavigateAsync(string pageKey, object[] parameter, bool animated = true)
{
var page = GetPage(pageKey, parameter);
await CurrentNavigationPage.Navigation.PushAsync(page, animated);
}
private readonly Stack<NavigationPage> _navigationPageStack = new Stack<NavigationPage>();
private NavigationPage CurrentNavigationPage => _navigationPageStack.Peek();
So it turns out in my navigation service, i was using the tabbedpage as a navigationpage to navigate to other pages, but if you get the current page (which should be encapsulated in a navigation while adding them as children to your tabbedpage), then using that if you navigate it creates a new page inside the current page instead of the whole tabbedpage
Here's my syntax for storing the currentPage as my navigation element to navigate
public Page SetRootPage(string rootPageKey = null, Page pageName = null)
{
NavigationPage tempPage = null;
if (rootPageKey != null)
{
var rootPage = GetPage(rootPageKey);
if (rootPage is TabbedPage tabbedRootPage)
{
tempPage = tabbedRootPage.CurrentPage as NavigationPage;
}
if (tempPage == null)
{
CurrentNavigationPage = rootPage is NavigationPage ? (NavigationPage)rootPage : new NavigationPage(rootPage);
}
else
{
CurrentNavigationPage = tempPage;
}
return CurrentNavigationPage;
// as NavigationPage;
//_navigationPageStack.Clear();
//var mainPage = new NavigationPage(rootPage);
// _navigationPageStack.Push(mainPage);
}
else
{
if (pageName is TabbedPage tabbedPage)
{
CurrentNavigationPage = tabbedPage.CurrentPage as NavigationPage;
}
else
{
CurrentNavigationPage = pageName as NavigationPage;
}
return CurrentNavigationPage;
}
}