View Not Shown, althought it is loaded !! SOLVED

Topics: Prism v4 - Silverlight 4
Feb 27, 2011 at 4:06 PM

Dear All,

I load a view using the following code:

RegionManager.RegisterViewWithRegion(RegionNames.AccountsDetailsRegion, () => ServiceLocator.Current.GetInstance<AccountsView>());

This view is showing a list of accounts, when the user select any and click edit, the view needs to load another View(with specific parameters) 
within the same region to show the details of the selected account
so I load the view using the following code:

  RegionManager.RequestNavigate(RegionNames.AccountsDetailsRegion, new Uri(builder.ToString(), UriKind.Relative),NavigationCompleted);

In the debugger the region manager successfully loads the view and I can see it, also the NavigationCompleted event handler shows no errors...

What is possibly causing this .... !!

Best regards


Feb 28, 2011 at 8:35 AM

I have found that I am using ItemsControl to host the region not a ContentControl ...

What is the difference, ItemsControl should be fine, right ...

One more thing related to the issue;

in the navigated view, I have a goback command and the navigationJournal is okay, but not going back, any help on this .

Best regards


Feb 28, 2011 at 1:37 PM

Dear all

If anyone is intrested, the fix is load the first view using RequestNavigate in order to register this view as the start of the navigation.

Best regards


Feb 28, 2011 at 7:07 PM

Hi Waleed,

I'm glad that you've solved your problem regarding navigation, and I thank you for sharing your insight with the rest of the community.

As regarding your initial concern, there should be no difference between using an ItemsControl and a ContentControl in your case. For example, you could check the HelloWorld QuickStart, which has a region that is hosted on an ItemsControl, in which a single item is added.

We've also tried adding a view to a region hosted in an ItemsControl using navigation, as you've done, and we faced no difficulties. Note that if you're using Unity as the Dependency Injection container, you should register a type mapping similar to the following in order for region navigation to work:




This is necessary since the default implementation of the RegionNavigationContentLoader internally tries to resolve an instance of type object with the name specified in the RequestNavigate method (which, in case you're using MEF, is the contract name specified in the Export attribute).

Here's the code of the RegionNavigationContentLoader.CreateNewRegionItem method to illustrate the aforementioned:


        protected virtual object CreateNewRegionItem(string candidateTargetContract)
            object newRegionItem;
                newRegionItem = this.serviceLocator.GetInstance<object>(candidateTargetContract);
            catch (ActivationException e)
                throw new InvalidOperationException(
                    string.Format(CultureInfo.CurrentCulture, Resources.CannotCreateNavigationTarget, candidateTargetContract),
            return newRegionItem;


If you are blocked by this behavior and can't find the reason why it happens, it could be helpful if you could provide us with a repro sample, so that we can help you diagnose what could be causing your issue.

I hope you find this helpful.

Guido Leandro Maliandi

Mar 1, 2011 at 5:09 PM

I agree with you the ItemsControl is the same as the ContentControl.

Appreciate your feedback...

I need to ask about the CreationPolicy of the views (shared). how can this be used ... I always get the view already exists when I call the RequestNavigate.

Any advice will be great.



Mar 1, 2011 at 5:20 PM

In order to specify that an export should not act as a singleton, you need to decorate your exported class with the PartCreationPolicy attribute in the following manner:


I hope you find this helpful.

Guido Leandro Maliandi

Mar 1, 2011 at 5:27 PM

Yes Guido, this is what I am doing ... but when I try to load the same view again using RequestNavigate I got an error saying view already exists !!

Is there any handling script to this, or this should be working automatically by PRISM .. as I assume.

Please advice


Mar 1, 2011 at 5:46 PM


The problem you're experiencing could be happening because the INavigationAware.NavigationTarget method in your view is returning true, hence the navigation service considers that the view already exists.

You might find the explanation in the Navigation chapter of the Prism MSDN documentation useful for this.

Guido Leandro Maliandi

Mar 1, 2011 at 7:54 PM

Dear Guido,

The explanation is understood ... what is the solution .. should I activate the existing view or what ...



Mar 2, 2011 at 2:29 PM

Hi Waleed,

The solution I referred to in my previous answer was to make the INavigationAware.NavigationTarget method in your view to return false.

In case that doesn't work, it would be helpful if you could provide us with further details regarding how you're implementing Navigation, or a repro sample for us to help you further.

I hope you find this helpful.

Guido Leandro Maliandi

Mar 5, 2011 at 9:39 PM

Dear Guido,

I found the solution in this post :

I implemented the IRegionMemberLifetime interface and everthing is working as excpected.