2

I have a route that is registered using the following

Routing.RegisterRoute("SchoolHome", typeof(SchoolHomePage));

I have a page with a list of schools and when I tap a School it executes this just fine from the ViewModel Command

Shell.Current.GoToAsync($"SchoolHome?schoolid={selectedSchool.Id}");

Here is my SchoolHomePage.xaml.cs

[XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class SchoolHomePage : ContentPage
    {
        public SchoolHomePage()
        {
            InitializeComponent();
            BindingContext = new SchoolHomeViewModel();
        }
    }

Here is a snippet of SchoolHomeViewModel.cs

[QueryProperty("School", "schoolid")]
    public class SchoolHomeViewModel : BaseViewModel
    {
        string school;
        public string School
        {
            get
            {
                return school;
            }
            set
            {
                SetProperty(ref school, Uri.UnescapeDataString(value));
            }
        }

So Shell doesn't map my QueryProperty to my property School and the page doesn't navigate. If I put the QueryProperty in the ContentPage's code behind and set the ViewModel's School property there, it will pass the value along but the page still doesn't navigate. It just stays on the page with the list of schools with the one I just tapped being selected.

Brentb25
  • 21
  • 1
  • 2
  • I could not find problem with the code you provided. Could you provide a basic demo for me to test? Here is a similar sample of shell, you can check it.https://learn.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/shell/introduction – Wendy Zang - MSFT Aug 28 '19 at 08:13

1 Answers1

-4

I found the problem. I had an issue with a property in my viewmodel. Once I fixed that it worked.

Brentb25
  • 21
  • 1
  • 2