Forum Xamarin.Forms

Shell navigation passing data not working

LarsNymandLarsNymand DKMember ✭✭

When navigating to ItemDetailPage page with query paramenter "id" I get below error (it works without paramenter)
System.ArgumentException: 'unable to figure out route for: //items/details?id=3ca6c981-52d6-4875-ae74-2e20fd878b77
Parameter name: uri'

ItemDetailPage is not a part of the Shell hierarchy and therefore registered in the AppShell constructor:
Routing.RegisterRoute("//items/details", typeof(ItemDetailPage));

In the ItemDetailPage I have added QueryProperty:
[QueryProperty("ItemId", "id")]
public partial class ItemDetailPage : ContentPage

and added ItemId property to the class:
private string itemId;
public string ItemId { get { return itemId; } set { itemId = Uri.UnescapeDataString(value); } }

I navigate to the page by calling:
await Shell.Current.GoToAsync($"//items/details?id={item.Id}");

What am I missing to make this work?
If I remove the "id" parameter from the GoToAsync call it navigates, but without id.

Thank you in advance


Sign In or Register to comment.