title: WPF MVVM view redirection from Viewmodel
body: <p>Am working with WPF MVVM, 
  I have a main window and few usercontrols.based on the button click am showing the view and viewmodels. When i click button in main window i can navigate to different view. because navigation command is in mainwindow viewmodel only. But when am in different view(user control) . How can i navigate from viewmodel.</p>
  
  <p><strong>MainwindowViewmodel</strong></p>
  
  <pre><code> public class MainWindowViewModel : BindableBase, INotifyPropertyChanged
  {
  
      private StudyViewModel _studyViewModel = new StudyViewModel();
      private ImageCaptureViewModel _imageCaptureViewModel = new ImageCaptureViewModel();
      private RegisterViewModel _registerViewModel = new RegisterViewModel();
  
      private BindableBase _CurrentViewModel;
  
      public BindableBase CurrentViewModel
      {
          get { return _CurrentViewModel; }
          set { SetProperty(ref _CurrentViewModel, value); OnPropertyChanged("_CurrentViewModel"); }
      }
  
      public MainWindowViewModel()
      {
          NavCommand = new RelayCommand&lt;string&gt;(onNav);
          onNav("study");
      }
  
     //This is the command am using in xaml to redirect view.
      public RelayCommand&lt;string&gt; NavCommand { get; private set; }
  
      private void onNav(string destination)
      {
          switch (destination)
          {
              case "study":
                  CurrentViewModel = _studyViewModel;
                  break;
              case "capture":
                  CurrentViewModel = _imageCaptureViewModel;
                  break;
              case "register":
                  CurrentViewModel = _registerViewModel;
                  break;
              default:
                  CurrentViewModel = _studyViewModel;
                  break;
          }
      }
  }
  </code></pre>
  
  <p><strong>RegisterViewModel</strong></p>
  
  <pre><code>  public void RegisterPatient(string action)
      {
          if (action == "addnew")
          {
  
          }
          else
          {
              if (StartImaging)
              {
                  //Have to redirect to other screen.
  
              }
          }
          var a = PatientToAdd;
          MessageBox.Show("triggered");
      }
  </code></pre>
  
  <p>When am adding command in mouse event it is redirecting .But i dont no how to redirect from viewmodel</p>
  
  <p><strong>RegisterView.xaml</strong></p>
  
  <pre><code> &lt;DataGrid.InputBindings&gt;
              &lt;MouseBinding Command="{Binding DataContext.NavCommand,RelativeSource={RelativeSource AncestorType={x:Type Window}}}"
          MouseAction="LeftDoubleClick"
         CommandParameter="historyimage"/&gt;
          &lt;/DataGrid.InputBindings&gt;
  </code></pre>