William Jockusch
William Jockusch

Reputation: 27295

WP7 NavigationService.Navigate pass a pointer without using global variables?

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 later navigated to.

I would also prefer not to have to serialize the banana.

Upvotes: 0

Views: 878

Answers (2)

AbdouMoumen
AbdouMoumen

Reputation: 3854

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 :)

Upvotes: 0

Matt Lacey
Matt Lacey

Reputation: 65564

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.

Upvotes: 3

Related Questions