Query Parameters and Navigation

Ronald Rex 101 Reputation points
2023-04-10T16:55:06.97+00:00

I have a MainPage View and then I have other views that are contained in a Shell Class with Routes. Below is my code which is a method SavePayer...Its an async Task in the MainPage View Model

async Task SavePayer()=> await Shell.Current.GoToAsync($"{nameof(TabbedPageWithNavigationPage)}?Mode={Mode}");

I was wondering how would I set the Mode Parameter to Edit and be able to see the Mode property in all of my views in the Shell? Thanks !!!

Developer technologies | .NET | .NET MAUI
Developer technologies | C#
0 comments No comments
{count} votes

Accepted answer
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 50,126 Reputation points Microsoft External Staff
    2023-04-11T05:22:45.14+00:00

    Hello,

    Through the official documentation, you could see that query parameters are only passed to the destination page:

    One or more query parameters. Query parameters are parameters that can be passed to the destination page while navigating.

    However, through your description, your requirements should be closer to how to use the value of mode as a global variable that can be accessed within the shell.

    I was wondering how would I set the Mode Parameter to Edit and be able to see the Mode property in all of my views in the Shell? Thanks !!!

    With this description, you could store Mode and Edit as Key/Value in Preferences so that you can get its value at any time.

    Best Regards,

    Alec Liu.


    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.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.