title: how to avoid multiple views reciving data from same viewmodel
body: <p>I'm bit confused with the behavior of my code. I'm still newbee in MVVM light.</p>
  
  <p>I have NewMessageWindow which is shown by command</p>
  
  <pre><code>    private ICommand newMessageCommand;
      public ICommand NewMessageCommand
      {
          get
          {
              if (newMessageCommand == null)
                  newMessageCommand = new RelayCommand(() =&gt;
                  {
                      new NewMessageWindow().Show();
                  });
              return newMessageCommand;
          }
      }
  </code></pre>
  
  <p>There can be multiple NewMessageWindows and each of them should have separate ViewModel. But I've noticed when I open multiple windows and if I change something in them it affects all windows. For example when I change combobox then combox values changes in all windows. </p>
  
  <p>How to avoid it? How can I open multiple windows with seprate viewmodels that wouldn't affect each other?</p>
  
  <p>Objects that are changing are <strong>ObservableCollections</strong> that are bound to view. </p>
  
  <p>Edit:</p>
  
  <p>This is how the ViewLocator looks like</p>
  
  <pre><code>    public NewMessageWindowModel NewMessage
      {
          get
          {
              return ServiceLocator.Current.GetInstance&lt;NewMessageWindowModel&gt;();
          }
      }
  </code></pre>
  
  <p>and in constructor</p>
  
  <pre><code>    SimpleIoc.Default.Register&lt;NewMessageWindowModel&gt;();
  </code></pre>
  
  <p>This is how binding looks like:</p>
  
  <pre><code> DataContext="{Binding NewMessage,
                            Source={StaticResource Locator}}"
  </code></pre>
  
  <p>I've fixed problem with </p>
  
  <pre><code> ServiceLocator.Current.GetInstance&lt;NewMessageWindowModel(System.Guid.NewGuid().ToString());
  </code></pre>
  
  <p>but I've read that old instances are cached. How to get rid of them?</p>