title: How to pass in my current window and drag it using a class method in C#
body: <p>My window drag is not working.
  here is my code :</p>
  <pre><code>    public WindowsButtonsVm(Window currentWindow)
      {
          _currentWindow = currentWindow;
      }
  
      public void MoveWindow(MouseButtonEventArgs e)
      {
  
          base.OnMouseLeftButtonDown(e);
  
          try
          {
              // Begin dragging the window
  
              _currentWindow.DragMove();
  
  
          }
          catch (Exception err)
          {
  
          }
      }
  </code></pre>
  <p>Current window is my main window that I passed in.</p>
  <p>my class WindowsButtonsVm  inherits from from this class:</p>
  <pre><code> public class ViewModelBase : UserControl, INotifyPropertyChanged
  {
      public event PropertyChangedEventHandler PropertyChanged;
  
      protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
      {
          PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
      }
  }
  </code></pre>
  <p>when the user does left mouse down on my header button is I called this :</p>
  <pre><code> private void HeaderBackgroundBtn_MouseDown(object sender, MouseButtonEventArgs e)
      {
         
          WindowsButtonsVm WindowBtn = (WindowsButtonsVm) WindowButtons1.DataContext;
  
          WindowBtn.MoveWindow(e);
          
      }
  </code></pre>
  <p>So I feel like I did everything right, but I am getting this error:</p>
  <pre><code>&quot;Can only call DragMove when primary mouse button is down.&quot;
  </code></pre>