Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Navigating to a details page - shared view model or navigation query string?

When navigating from a list page to a details page, there are two high level ways of passing the selection data between the pages: sharing a view model instance and passing an identifier in the querystring of the navigation Uri.

Which should I be using? Are there any issues with using one approach over the other (access to current Uri from the view model, timing of navigation events, etc)?

like image 691
Richard Szalay Avatar asked Jun 09 '11 07:06

Richard Szalay


1 Answers

Personally I would recommend passing an identifier as part of the navigation URI querystring. These URIs are restored to form the back-stack when your application re-enabled after tombstoning.

When your application is restored after being tombstoned, you re-create your applications view model from the application state, then use the URI querystring to 'marry' your newly created view with its required DataContext.

See the worked example here:

http://www.scottlogic.co.uk/blog/colin/2011/05/a-simple-windows-phone-7-mvvm-tombstoning-example/

like image 125
ColinE Avatar answered Nov 09 '22 12:11

ColinE