locked
Displaying MasterDetail menu programmatically RRS feed

  • Question

  • User330867 posted

    Hi,

    I have hidden the NavigationPage inside my shared project and I am able to display the menu on the left by swiping, but I was wondering if I can show that menu programmatically perhaps from a TapGesture?

    Friday, June 22, 2018 11:17 AM

All replies

  • User330867 posted

    I answered my own question and share it for benefit of others.

    I was initially suggested to use:

    (App.Current.MainPage as MasterDetailPage).IsPresented = true;

    But I was worried it might not work as my app could use a different page as its MainPage so I made a binding for IsPresented and it works.

    EDIT:

    I found unexpected behaviour when using this method so what really helped me was using a singleton class called Context:

    Context.Instance.mp = new MainPage();
                MainPage = Context.Instance.mp;
    

    And then when I want to display that menu, I use:

    void Handle_Clicked(object sender, System.EventArgs e)
            {
    
                Context.Instance.mp.IsPresented = true;
    
            }
    
    Friday, June 22, 2018 11:42 AM
  • User369473 posted

    @amirvenus said: I answered my own question and share it for benefit of others.

    I was initially suggested to use:

    (App.Current.MainPage as MasterDetailPage).IsPresented = true;

    But I was worried it might not work as my app could use a different page as its MainPage so I made a binding for IsPresented and it works.

    EDIT:

    I found unexpected behaviour when using this method so what really helped me was using a singleton class called Context:

    Context.Instance.mp = new MainPage();
                MainPage = Context.Instance.mp;
    

    And then when I want to display that menu, I use:

    void Handle_Clicked(object sender, System.EventArgs e)
            {
    
                Context.Instance.mp.IsPresented = true;
    
            }
    

    Can you shown me how to place toolbar items in the left ,after that to open a menu in the left when I click the icon ?

    Saturday, June 23, 2018 2:54 PM
  • User330867 posted

    @Endrit14 said:

    Can you shown me how to place toolbar items in the left ,after that to open a menu in the left when I click the icon ?

    Placing on the left? I believe they are on the left by default!

    Or did you mean right like eBay search filter style?

    Saturday, June 23, 2018 9:46 PM
  • User369473 posted

    @amirvenus said: > @Endrit14 said: > > Can you shown me how to place toolbar items in the left ,after that to open a menu in the left when I click the icon ?

    Placing on the left? I believe they are on the left by default!

    Or did you mean right like eBay search filter style?

    I have a TabbedPage and I want to create a menu icon to slide from the left ,can you help me ?

    Sunday, June 24, 2018 9:21 AM
  • User22454 posted

    @amirvenus When I try (App.Current.MainPage as MasterDetailPage).IsPresented = true; I get a null reference -- the cast does not work. Do you have any suggestions and/or can you expand on the context?

    Friday, February 28, 2020 5:00 PM