title: Collection was modified; enumeration operation may not execute
body: <p>I get this error when I try and close views in our silverlight application with an MVVM framework</p>
  
  <p>Collection was modified; enumeration operation may not execute.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>ObservableCollection&lt;IViewModel&gt; _viewModels = new ObservableCollection&lt;IViewModel&gt;();
  
          var _viewManager = AppContext.Current.ViewService.GetViewManager("Main");
          var _views = _viewManager.OpenViews;
  
          _viewModels = _views;
  
          foreach (var _vm in _viewModels)
          {
              _viewManager.CloseView(_vm);
          }
  </code></pre>