Xamarin.Forms - Master/detail page and navigation history issue

后端 未结 3 542
抹茶落季
抹茶落季 2020-12-31 12:50

I have an app which uses masterdetail page to show menu in all page. The navigation is happened in two way in my app. one from the menu and second way from Dashboard. so if

3条回答
  •  孤城傲影
    2020-12-31 13:11

    Like what @Sten-Petrov said: you are replacing the detail page and not triggering the history mechanism. To trigger the history mechanism you will need to do a PushAsync(Page) on the Navigation property of the Detail page.

    In your example, change NavigateTo:

     void NavigateTo (MenuItem menu)
     {
         Page displayPage = (Page)Activator.CreateInstance (menu.TargetType);
         Detail.Navigation.PushAsync(displayPage);
     }
    

    This will not replace the content but will bring up a new page with the back button functionality you want.

    If you want back button functionality with the Master-Detail page then you'll need to customize the back stack process which, in my opinion, is not worth it. Just move to a different page/navigation structure in that case.

提交回复
热议问题