Shell navigation with dynamic content

357 Views Asked by At

To contrive an example, let's say I have an application that catalogs a library of books by author. What I am attempting is a Shell flyout that lists all of the authors and selecting an author from that list will display a page that lists all of the books by that author.

Naively, I would assume that I could have an Author page that could take a route parameter of an author id (//author/{authorId} or //author?authorId={authorId}). I'm unclear how I would set up flyout items to work with that. The list of authors is loaded dynamically from a web service, can I register custom routes for each item that will resolve to what I'm trying to hit?

How can I set this up or am I really barking up the wrong tree? I get that I could use the BindingContext from the ShellContent itself, but is that going to be available if I were to do something like use that uri to navigate into the app from another one?

1

There are 1 best solutions below

0
On

You could change the flyout item at runtime by adding it in code behind.

Suppose this is a button event handler,

    private void OnCounterClicked(object sender, EventArgs e)
    {
       
        AppShell.Current.Items.Clear();

        //add new flyout item
        ShellContent content = new ShellContent();
        content.Title = "test";
        content.Content = new MyPage();

        AppShell.Current.Items.Add(content);
    }