My home page is implemented as a FlyoutPage, with the detail page set as a TabbedPage and the flyout serving as the menu page. The TabbedPage contains three tabs in the order of Alerts, Home, and Menu.
The issue occurs when I select the first option, "Appointments," from the menu and navigate to that page. Upon clicking the back button from the Appointments page, the appointments page is closing and menu pop up will open again, if i close menu, the Home tab is displayed, if I then switch to the Alerts tab now, the Appointments page appears there instead of the Alerts page, if I click back button again the app will break with below exception.
Java.Lang.IllegalStateException: 'The specified child already has a parent. You must call removeView() on the child's parent first.'
Below code is using for back tap on Appointments page:
private void HandleTapped(object sender, System.EventArgs e)
{
var navStack = Navigation?.NavigationStack;
if (navStack?.Count == 2)
{
var dashboardMasterPage = MainService.HomePage.Value as DashboardMasterPage;
if (dashboardMasterPage is DashboardMasterPage)
{
dashboardMasterPage.IsPresented = !dashboardMasterPage.IsPresented;
}
}
ViewModel.Navigation.Pop();
}
I have updated it like below:
private async void HandleTapped(object sender, System.EventArgs e)
{
var master = MainService.HomePage?.Value as DashboardMasterPage;
if (master != null)
{
// Reset Detail page back to the DashboardTabPage
master.Detail = new NavigationPage(new DashboardTabPage());
master.IsPresented = false;
}
}
With the above update, when I click on back button the entire home page is reopening again.
But my requirement is to close the appointment page only and reopen the menu pop up when tap on back button from appointment page.