title: How to pass a reference to an object through CommandParameter
body: <p>I have a MainViewModel class which is the basis for my navigation.</p>
  
  <p>Within that class I have this method with the purpose of changing the parameter object passed in to the selected vendor.</p>
  
  <pre><code>class MainViewModel
  {
          public Command ShowVendorDialogCommand
          {
              get;
              private set;
          }
          private void ShowVendorDialog(object parameter)
          {
              if (parameter != null)
              {
                  VendorDialog vd = new VendorDialog();
                  VendorDialogViewModel vm = new VendorDialogViewModel();
                  vd.DataContext = vm;
                  vm.PropertyChanged += (s, e) =&gt;
                  {
                      if (e.PropertyName == "CloseDialog")
                      {
                          vd.Close();
                      }
                  };
                  vd.ShowDialog();
  
                  if (vm.DialogResult)
                  {
                      parameter = vm.SelectedVendor.Copy() as Vendor;
                  }
              }
          }
  }
  </code></pre>
  
  <p>The class that is affected by this method is below:</p>
  
  <pre><code>    class InventoryStyleSingleViewModel
      {
              public Vendor
              { 
                   get
                   {
                        return _Vendor;
                   }
                   set
                   {
                        if (value != null)
                        {
                             _Vendor = value;
                             OnPropertyChanged("Vendor");
                        }
                   }
              }
              private Vendor _Vendor;
  
              ........
      }
  </code></pre>
  
  <p>I am essentially trying to pass the Vendor property as a reference type through the CommandParameter property to the ShowVendorDialog which is executed through a RelayCommand, I am just not sure how to accomplish the reference part.</p>
  
  <p>Here is the xaml that binds to the ShowVendorDialogCommand.</p>
  
  <pre><code>&lt;Button Width="50" DockPanel.Dock="Left" Command="{Binding ElementName=BeginWindow, Path=DataContext.ShowVendorDialogCommand}" CommandParameter="{Binding Vendor}" Content="..." /&gt;
  </code></pre>
  
  <p>This does not accomplish what I need as the Vendor property is passed by value into the ShowVendorDialog function.</p>
  
  <p>Is there anyway to pass the Vendor by reference?</p>