Shell Navigation and passing Parameter Values

Ronald Rex 1,666 Reputation points

Hi friends, I was wondering how to pass multiple parameters. I can pass one parameter for now... ?Name={Name}


Task Navigate() =>
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,216 questions
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,633 questions
0 comments No comments
{count} votes

Accepted answer
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 71,936 Reputation points Microsoft Vendor


    If you want to pass multiple parameters, you can send them by Dictionary. Or create an object that contain these parameters. put this Object to the Dictionary and send it, here is a similar thread: Passing Parameters using QueryParameter in MAUI.

     Package package=  new Package() { packageId = lbl.Text, packageName = "yourpageName" };  
     var navigationParameter = new Dictionary<string, object> { { "MyPackage", package } };  
     await Shell.Current.GoToAsync($"MyPage2", navigationParameter);  

    You can get this object in the MyPage2's background code.

    [QueryProperty(nameof(MyPackage), "MyPackage")]  
       public partial class MyPage2 : ContentPage  
           public Package MyPackage  
           public MyPage2()  
          public async void ShowMessage(Package package)  
               var id = package.packageId;  
               var name = package.packageName;  
              await DisplayAlert("Query", id+ name, "Ok");  

    If you want to get these parameters in the ViewModel, you need to achieve IQueryAttributable interface and get parameters in the ApplyQueryAttributes method.

    public class Page2ViewModel : IQueryAttributable
        public void ApplyQueryAttributes(IDictionary<string, object> query)
           Package myPackage= query["MyPackage"] as Package;
           var id=  myPackage.packageId;
           var packageName= myPackage.packageName 

    Here is a document about passing and processing multiple items of data in shell with QueryProperty.

    Best Regards,

    Leon Lu

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    5 people found this answer helpful.

0 additional answers

Sort by: Most helpful