How to do Dynamic page navigation in xamarin forms?

sagarsagar ✭✭Member ✭✭

I am working on xamarin.forms. Where I need to do navigation based on menu clicked. It's a dynamic menu, order of menus might change or based on the user logged in the menus will be changing. What I need to do is I will get from API to which page I should navigate, I need to pass that page name dynamically.

For example
var dynamicpage = "MenuPage()";
new NavigationPage (new dynamicpage );// Like this

Is it possible or not? If yes please help me out.

Best Answer

Answers

  • JohnHardmanJohnHardman mod GBUniversity mod

    @sagar said:
    I am working on xamarin.forms. Where I need to do navigation based on menu clicked. It's a dynamic menu, order of menus might change or based on the user logged in the menus will be changing. What I need to do is I will get from API to which page I should navigate, I need to pass that page name dynamically.

    For example
    var dynamicpage = "MenuPage()";
    new NavigationPage (new dynamicpage );// Like this

    Is it possible or not? If yes please help me out.

    (1) Note that other than your root page, you don't wrap subsequent pages in new NavigationPage(...)
    (2) There are various ways of doing what you ask. You could consider the Factory pattern (Google for details), but it's not the only way

Sign In or Register to comment.