I am navigating to page X in WP7. I have an object (let's call it banana) in my ViewModel, which is where the NavigationService.Navigate call is being made. Page X needs a reference to the banana. How can I do that?
The answer to this question recommends using the global App class. Not a good option for me because I might have multiple instances of the class of page X, and I wouldn't want to confuse other instances if they are lat开发者_StackOverflow中文版er navigated to.
I would also prefer not to have to serialize the banana.
If there could be multiple instances of the page then you'll need to pass any parameters it needs as part of the querystring in the Uri you use for navigation.
You can either use the query string (to send the id, for example) as suggested by @Matt, and you could also send the object itself via a message for example, you can use the Messenger
class from MVVM Light for that.
Hope this helps :)
精彩评论