Multiple instances of the same View

Topics: Prism v4 - Silverlight 4
Apr 27, 2011 at 9:55 AM
Edited Apr 27, 2011 at 9:56 AM


I'm new to Prism and I'm building a sample application using Silverlight4, Prism 4 with MEF.

In the Shell have a TabControl defined as a region where I load my Main Content. Since it's a Tab control I want to load multiple views in it and be able to navigate between them. 

I have a View that Lists the "Customers" from my database. By selecting one Customer and click the Details button, I navigate to the "Edit Customer Details" View that opens in a new tab.

So far, so good.

The problem is when I try to Edit 2 Customers: I choose the customer, Edit, and a new tab is created. I choose another Customer, Edit and nothing happens. 

In the CustomersList ViewModel I have the following code:


UriQuery uriQuery = new UriQuery();
var _customer = customersList.CurrentItem as Customer;

if (_customer != null)
   uriQuery.Add(EditCustomerViewName, _customer.ID);

Uri EditCustomerViewUri = new Uri(EditCustomerViewName + uriQuery.ToString(), UriKind.Relative);
this.regionManager.RequestNavigate(RegionNames.MainContentRegion, EditCustomerViewUri);


I saw some solutions but it involved that the ViewModel inserted directly the View into the region, but I saw somewhere that the ViewModel should be "View Independent".

Anyone knows how can I load multiple instances of the same View from the ViewModel?


Thanks in advance.

Best regards,

Ricardo Bentes

Apr 27, 2011 at 1:41 PM

Hi Ricardo,

Based on my understanding of your scenario, the problem you’re experiencing might be happening by the fact that IsNavigationTarget implementation of the INavigationAware interface is returning True, which means that your target view (EditCustomerView) will be re used and will ensure that only one view will be displayed in the region, in your case the tab control.

On the other hand, you should make sure that your EditCustomerView view is decorated with the PartCreationPolicy attribute as NonShared. By doing this, a new instance of the exported view model will be created each time it is resolved.

Also take into account that Prism provides the IRegionMemberLifetime interface, which allows you to control the lifetime of views within regions by allowing you to specify whether deactivated views are to be removed from the region or simply marked as deactivated. 

Additionally, you can read the following links about Navigation:

I hope you find this information useful.


Miguel Bronzovic

Apr 27, 2011 at 2:38 PM

Hi Miguel,


Thank you for your answer, it was very helpful, indeed what was missing was just the PartCreationPolicy attribute.

Actually  I had to add the PartCreationPolicy attribute not only to the view, but also to the ViewModel because all Edit Views were sharing the same instance of View Model and consequently showing the same information.


Once again,

Thank you!