title: How to create new instance of a view/viewmodel when navigation occurs with Prism
body: <p>I am trying to control when a new view is created and when an existing view is shown.</p>
  
  <p>This is a very similar scenario as outlined in the "Navigating to Existing Views" section in the Prism documentation, but I can't get it to work fully:
  <a href="http://msdn.microsoft.com/en-us/library/gg430861(v=pandp.40).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/gg430861(v=pandp.40).aspx</a></p>
  
  <p>I am finding I can create the view/view model to begin with ok, but I am then unable to create a new instance of it.  I.e. I want more than one instance to exist at once.</p>
  
  <p>Here's an example of the view model:</p>
  
  <pre><code>[Export]
  [PartCreationPolicy(CreationPolicy.NonShared)]
  public class DataEntryPageViewModel : INavigationAware, IRegionMemberLifetime
  {
      private Guid id;
  
      [ImportingConstructor]
      public DataEntryPageViewModel()
      {
          id = Guid.NewGuid();
      }
  
      public bool IsNavigationTarget(NavigationContext navigationContext)
      {
          // In actual fact there would be more logic here to determine
          // whether this should be shown to the user
          return false;
      }
  
      public void OnNavigatedFrom(NavigationContext navigationContext)
      {
      }
  
      public void OnNavigatedTo(NavigationContext navigationContext)
      {
      }
  
      public bool KeepAlive
      {
          // For the purposes of this example we don't want the view or the viewModel
          // to be disposed of.
          get { return true; }
      }
  }
  </code></pre>
  
  <p>I am navigating to this as follows:</p>
  
  <pre><code>m_RegionManager.RequestNavigate(
                 "MainRegion",
                 new Uri("/DataEntryPageView", UriKind.Relative));
  </code></pre>
  
  <p>So the first time I call the above the view is shown.</p>
  
  <p>The next time I call RequestNavigate the IsNavigationTarget is hit and it returns false.  What I then want it to do is to create a new instance but that doesn't happen.  I know it's not happening because the constructor does not get hit and the UI does not update to show the new instance of the view.</p>
  
  <p>Any ideas how I can make it create a new instance?</p>
  
  <p>Many thanks,</p>
  
  <p>Paul</p>
  
  <p><strong>Edit</strong></p>
  
  <p>I have noticed that the second time I call RequestNavigate (to request another instance of the same view) the callback reports an error "View already exists in region."  It therefore seems that I can have multiple instances of different views in a region, but not multiple instances of the same view. My understand of this isn't great though so I could be wrong.</p>