Issue
I see how to pass data in the form of strings from one object to another
What I want to do, however, is pass an object from one vm to another -- is this possible? I can think of these ideas:
- Stream the object as json and pass that as a param.
- Use an id to look up and create the object in the receiving vm
- Pass the object itself (ideal)
Will any of these work (well, #2 almost certainly will)? If 1 or 3 will work, can you possibly supply (detailed?) instructions on how to do so?
Thanks!! jesse liberty
Solution
Put the following at the top of the page that will be receiving the data
[QueryProperty(nameof(CodesToAdd), nameof(CodesToAdd))]
Create a corresponding property (in this case CodesToAdd)
In the setter for that property getg the string value passed to you
_codesToAdd = Uri.UnescapeDataString(value ?? string.Empty);
To send the data (in this case the codes to add) put this in the calling program:
await Shell.Current.GoToAsync($"{nameof(AddWidgetPage)}?CodesToAdd={codesToAddAsString}");
The first part in the parens identifies the page you want to navigate to. The part after the ? is the parameter. Make sure your param name (CodesToAdd) matches the one in your receiving page.
Answered By - Jesse Liberty
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.