title: Pass parameter to a constructor in the ViewModel
body: <p>I am building a WPF browser application with MVVM pattern.</p>
  
  <p>I have a first page (ConsultInvoice) with a dataGrid. When I double click on one of the row I want to navigate to another page (EditInvoice) passing the selected row in argument to my constructor.</p>
  
  <p>I know if I want do things properly I should use a dependency injection, but I don't really see how to use it here.</p>
  
  <p>How can I simply pass this constructor?</p>
  
  <p><strong>ConsultInvoiceViewModel</strong></p>
  
  <pre><code>private Invoice _selected;
  public Invoice Selected
  {
      get
      {
          return _selected;
      }
      set
      {
          _selected = value;
          OnPropertyChanged("Selected");
      }
  }
  
  private void Edit()
  {
      EditInvoiceViewModel editInvoice = new EditInvoiceViewModel(Selected); 
     /* doing something here*/
  }
  
  public ICommand EditCommand
  {
      get
      {
          return editCommand ?? (editCommand = new RelayCommand(p =&gt; this.Edit(), p =&gt; this.CanEdit()));
      }
  }
  </code></pre>
  
  <p><strong>EditInvoiceViewModel</strong></p>
  
  <pre><code>public class EditInvoiceViewModel : ViewModelBase
  {
      public Context ctx = new Context();
      Invoice invoice;
      PreInvoice preInvoice;
      #region properties
      private ObservableCollection&lt;PreInvoice&gt; collection;
      public ObservableCollection&lt;PreInvoice&gt; Collection
      {
          get
          {
              return collection;
          }
          set
          {
              collection = value;
              OnPropertyChanged("Collection");
          }
      }
      #endregion
      public EditInvoiceViewModel(Invoice inv)
      {
          /* do stuff*/
      }
  }
  </code></pre>