MasterDetail & TabbedPage - Push NavigationPage

ToHa1798ToHa1798 USMember ✭✭

Hello,
I use a MasterDetailPage which uses a TabbedPage with a ListView as "Detail".
Now, when I click an item in the ListView, I want a NavigationPage to be displayed.
I would like this page to be displayed with "Navigation.Push". Unfortunately, this page is not pushed across the entire screen.
Is there a solution for this?

Many many thanks

Best Answer

Answers

  • ToHa1798ToHa1798 USMember ✭✭

    Hello @TomasKlejna
    Thank you very much for your fast answer - It works!

    Now I have another problem - My MasterDetailPage has a method "ShowPage()" I want to be able to call it from the whole application, if I make the MasterDetail object static and call the method from another class, a NavigationPage will be pushed, the back button (left allow) does not work anymore.
    Is there a solution for this?

  • seanydaseanyda GBMember ✭✭✭✭✭

    @ToHa1798 said:
    Hello @TomasKlejna
    Thank you very much for your fast answer - It works!

    Now I have another problem - My MasterDetailPage has a method "ShowPage()" I want to be able to call it from the whole application, if I make the MasterDetail object static and call the method from another class, a NavigationPage will be pushed, the back button (left allow) does not work anymore.
    Is there a solution for this?

    Probably because you're using a new instance of NavigationPage so the previous page isn't in the NavigationStack. Ideally, you don't want to be making your MasterDetailPage static. You can call Navigation.PushAsync from anywhere in the NavigationPage.

  • ToHa1798ToHa1798 USMember ✭✭

    Hello @seanyda
    thank you for your answer.

    I tried your suggestion, unfortunately without success.
    I try to explain my structure.

    My MasterDetailPage contains as a detail a TabbedPage - This contains a ContentPage with a ListView.
    If I click on an item in the ListView, an “info page” should be pushed over the MasterDetail. If you now close this “info page” (PopAsync) then you should be again in the MasterDetail.
    many many thanks

  • seanydaseanyda GBMember ✭✭✭✭✭

    @ToHa1798 said:
    Hello @seanyda
    thank you for your answer.

    I tried your suggestion, unfortunately without success.
    I try to explain my structure.

    My MasterDetailPage contains as a detail a TabbedPage - This contains a ContentPage with a ListView.
    If I click on an item in the ListView, an “info page” should be pushed over the MasterDetail. If you now close this “info page” (PopAsync) then you should be again in the MasterDetail.
    many many thanks

    No problem, If you can ZIP your project, I'll take a look and see if I can fix the issue for you.

  • ToHa1798ToHa1798 USMember ✭✭

    Hello @seanyda

    sorry i cannot ZIP the whole Project, cause im not the projectowner, but however, I could copy the most important ones.

    First of all, i set a variable of MasterDetail:

    `
    public static class CommonSettings
    {
    [ThreadStatic]
    private static MasterDetail m_MasterDetail;

      public static MasterDetail MasterDetailPage
      {
          get
          {
              if (m_MasterDetail == null)
              {
                  m_MasterDetail = new MasterDetail();
              }
    
              return m_MasterDetail;
          }
     }
    

    }

    `

    After login, i set the current page:

    Application.Current.MainPage = new NavigationPage(CommonSettings.MasterDetailPage);

    This is the Click-Event in the ListView which is set in the MasterDeatail Detail section:

    `
    protected virtual void onItemTabbed(object sender, ItemTappedEventArgs e)
    {
    CommonSettings.MasterDetailPage.TestPush();
    }

    `

    This is my MasterDetailPage:

    `
    public class MasterDetail : MasterDetailPage
    {
    public MasterDetail()
    {
    this.ToolbarItems.Add(new ToolbarItem(TranslationManager.GetTranslation(TranslationType.Control_Action_Back), Images.CloseButtonImage, () => { TestPush(); }, ToolbarItemOrder.Primary, 1)); //that work

            NavigationPage.SetHasBackButton(this, false);
            NavigationPage.SetHasNavigationBar(this, false);
    
            this.Master = new MainMenuPage
            {
                Title = TranslationManager.GetTranslation(TranslationType.MainMenuPage_Page_Title) //IOS
            };
    
            this.Detail = new PageController(); //tabs
        }
    
        public void TestPush()
        {
            this.Navigation.PushAsync(new CustomerPage(RepositoryItem.Customer.All().FirstOrDefault()));
        }
    }
    

    }

    `

    Sorry for the bad formatting - I try to edit it

  • ToHa1798ToHa1798 USMember ✭✭

    I solved the Problem - I had a bug with the onAppearing Event in LiveView - This Event crashed the app if the page is poped.
    Thank you for your help!

Sign In or Register to comment.