Quantcast
Channel: patterns & practices: Prism
Viewing all articles
Browse latest Browse all 1878

New Post: Prism-MEF: using UriQuery to dynamically adding tabitems

$
0
0

Hi there,

When using navigation requests the parameters you can pass in the UriQueryare limited to strings only; hence, its not possible to pass an entire object (unless you can serialize it in astring and recreate it based on it, although this not always recommended)

Based on my understanding, the usual approach in this kind of scenarios is to pass only an ID which you can use to identify the corresponding model (for example, theSubsystemNo parameter you are adding to the Uri) and then obtain that model in theOnNavigatedTo method by using that ID, which you can retrieve from theNavigationContext's Parameters:

publicvoid OnNavigatedTo(NavigationContext navigationContext)
{string id = navigationContext.Parameters["SubsystemNo"];
    ...
}
How you would obtain the model based on this ID will depend mostly of the architecture of your application. For example, you could obtain the model from a repository or shared service that could be in charge of managing the models. Another approach could be to simply store the model in a shared service before requesting the navigation and then retrieve the model from that service in theOnNavigatedTo method.

I hope you find this useful,

Damian Cherubini
http://blogs.southworks.net/dcherubini


Viewing all articles
Browse latest Browse all 1878


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>