title: Opening new window from ViewModel
body: <p>How should I be opening new windows? I'm currently doing the following.</p>
  
  <p>EventArgs:</p>
  
  <pre><code>public class GenericViewRequestedEventArgs : EventArgs
  {
      public GenericViewModel ViewModel { get; private set; }
  
      public GenericViewRequestedEventArgs(GenericViewModel viewModel)
      {
          ViewModel = viewModel;
      }
  }
  </code></pre>
  
  <p>ViewModel:</p>
  
  <pre><code>public class MainWindowViewModel : ViewModelBase
  {
      private RelayCommand _viewSpecificCommand;
  
      public ICommand ViewSpecificCommand
      {
          get
          {
              if (_viewSpecificCommand == null)
                  _viewSpecificCommand = new RelayCommand(x =&gt; viewSpecific());
  
              return _viewSpecificCommand;
          }
      }
  
      public EventHandler&lt;GenericViewRequestedEventArgs&gt; GenericViewRequested;
  
      private void RaiseGenericViewRequested(GenericViewModel viewModel)
      {
          var handler = GenericViewRequested;
          if (handler != null)
              handler(this, new GenericViewRequestedEventArgs(viewModel));
      }
  
      private void viewSpecific()
      {
          RaiseGenericViewRequested(_specificViewModel);
      }
  }
  </code></pre>
  
  <p>View:</p>
  
  <pre><code>public partial class MainWindow : Window
  {
      private void OnGenericViewRequested(object sender, GenericViewRequestedEventArgs e)
      {
          GenericWindow window = new GenericWindow(e.ViewModel);
          window.ShowDialog();
      }
  }
  </code></pre>
  
  <p>This does work, but it seems like a lot of code and I end up with code behind in my view any ways. </p>
  
  <ul>
  <li>What's the logic behind sending the command to the viewmodel at all? </li>
  <li>Is it just to optionally use the predicate(if so why not bind to Enabled) and possibly avoid exposing additional viewmodels as properties? </li>
  <li>Should I be attaching simple event handlers in the XAML(e.g. <code>Click="btnViewSpecific_Click"</code>)?</li>
  </ul>