RegisterViewWithRegion and RequestNavigate

Topics: Prism v4 - WPF 4
Feb 7, 2012 at 2:58 AM
Edited Feb 7, 2012 at 3:00 AM

Hi Experts,

Is there any way to use RegionManager's RegisterViewWithRegion and RequestNavigate together? I make use of RegisterViewWithRegion at initialization because the region is not yet registered moment. Then, to change the view in the region at a later moment I make use of RequestNavigate. The problem with this setup is that for RequestNavigate to work, the view should be exported explicitly using


as described here:

Important: 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.
For instance, in Unity you will need to register your views against the Object type, map it to
your view type, and provide a name that matches the one used in the navigation URI. 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. 

The problem now is that RegisterViewWithRegion now cannot find the export anymore when using

regionManager.RegisterViewWithRegion(RegionNames.MyRegion, typeof(MyView))

Is there any way to solve this or is using both methods together not recommended anyway?

Thanks in advance,


Feb 7, 2012 at 3:31 PM


I believe you might find the following work item useful, where a possible workaround is suggested, to achieve a similar scenario:

Additionally, as we saw you're mentioning you're using a contract name that is different to the type of your view, you could find the following blog post interesting, where the differences between the contract name and type name are explained, and the possible problems you might get when exporting a view with a contract name (string) different than the name of the view’s type:

I hope you find this handy,

Agustin Adami

Feb 7, 2012 at 6:51 PM

Hi aadami,

The extension method in the first link you supplied does exactly what i need. I searched the discussions before posting but forgot about the issue tracker. Oops. The contract name I use is not different from the view name, I wrote it that way to make things more clear but I guess it had the opposite effect.

Thanks for explaining this to me :-)

Feb 7, 2012 at 7:03 PM


I'm glad you found the extension method proposed in the work item useful.

As we realize it might not be straightforward to find it in the work items section, we added an entry into the UI Composition section of the knowledge base so that it's easier to be found on future occasions.


Guido Leandro Maliandi

Feb 8, 2012 at 12:51 AM

Good Idea!

Thanks again!