Basic Question on URI

Topics: Prism v4 - Silverlight 4
Sep 9, 2011 at 8:53 AM

New to this..

I am porting my SL project to prism.

I have multiple (4) modules. One of them is the CommandDispatch Module which essentially houses a toolbar. This sits in the "CommandRegion" of the window - at the top.

When I click on certain buttons, I want the different views to be places in the main "contentregion"

In each module I have a View and ViewModel.

So, my project structure is something like




and so on....

Since these are all separate modules and separate project, I am confused about how to create a URI within my commandDispatchViewModel.cs that navigates to Module1.

At the top of the class definition of Module1, I decorate with [Export ("Module1View")]

when I need to navigate, I have tried:
    regionManager.RequestNavigate("ContentRegion", new Uri("/Module1View;component/Module1", UriKind.Relative));    
    regionManager.RequestNavigate("ContentRegion", new Uri("/Module1View;component/Module1.ViewModels", UriKind.Relative)); 

and a couple of other combinations.

So, HOW DO I compose the URI?






Sep 9, 2011 at 5:53 PM


By default, the navigation URI specifies the contract name of a view that is registered in the container. Therefore you could create your URI like the code below:

regionManager.Regions["MyRegion"].RequestNavigate(new Uri("Module1View", UriKind.Relative));

When the region navigation service creates a view, it requests a type of Object from the container with a name that matches the one supplied in the navigation URI.

Various containers provide different registration mechanisms to support this.

In MEF, it is implemented differently and only the contract name is used. Therefore, as long as the view is exported with a contract name that matches the name in the URI request, the view can be successfully constructed.

You'll find more information regarding that in the Prism documentation:

I hope you find this helpful

Agustin Adami

Sep 10, 2011 at 3:12 PM

Thanks aadami. Will check out the refrence.