Same View Created Multiple Times

Topics: Prism v4 - Silverlight 4
Apr 20, 2011 at 9:48 AM

In ModuleInit I am loading the same view into the region twice by using different parameters in the  constructor, like:


this.regionManager.Regions["MainNavigationRegion"].Add(new FillRateNavigationItemView("Overall"), "Overall");

this.regionManager.Regions["MainNavigationRegion"].Add(new FillRateNavigationItemView("Projectors"), "Projectors");


I have ViewModel attached to the view like:


public EpsonColumnViewModel ViewModel {

    set { this.DataContext = value; }

    get { return (EpsonColumnViewModel)this.DataContext; }



The problem is that ViewModel is instantiated only once and both view display the same values. I would need the ViewModel to calculate values for both instances of the view. What is a good approach here?

Apr 20, 2011 at 2:50 PM


Based on my understanding of your scenario, you need to decorate your EpsonColumnViewModel class 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. For example in your code it would look like this:

public class EpsonColumnViewModel : IEpsonColumnViewModel

I hope you find this information useful.


Miguel Bronzovic

Apr 21, 2011 at 5:38 PM

Yeah. That's it. Thanks Miguel.