MAUI routing in the Shell

  Kiến thức lập trình

I’m trying to setup some routing on shell items in a Maui application as there appears to be a consensus that this is the correct thing to do.

My routes are getting added dynamically as I’m requesting remote data to decide what options should be present

This registers correctly

Shell.Current.Items.Add(new ShellContent()
                Title = server.ServerName,
                Route = $"{this.SystemConnection.Name}_{server.ServerName}",
                ContentTemplate = new DataTemplate(() => new ServerHomePage(new ServerViewModel(this.client, server)))

and then I can navigate to it with this

await Shell.Current.GoToAsync($"///{this.SystemConnection.Name}_{details.ServerName}");

As soon as I try and make the route hierarchical with

Route = $"{this.SystemConnection.Name}/{server.ServerName}"

The route can no longer be found regardless of the route I pass to GoToAsync.

Is it possible to add hierarchical routes programmatically?

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website