title: How to close WPF User Control window
body: <p>I have a question about closing a User Control Window.</p>
  
  <p>In this application the main window will have a button to open the User control Window. In the User Control Window there are two buttons: one is to save and the other is to cancel. In the cancel click event, the user control alone needs to get closed and get back to the main window.</p>
  
  <p>This code is closing the main window, too.</p>
  
  <pre><code>private void btnCancel_Click(object sender, RoutedEventArgs e)
  {
      var mywindow = Window.GetWindow(this);
      mywindow.Close();
  }
  </code></pre>