title: WPF Window Closing does not work after Cancel
body: <p>I have an issue that I can't seem to resolve via Google (likely because I'm not searching the right criteria). I have a Closing Event that checks if a button is enabled and pops a messagebox  with a result (Yes/No). If the user says NO, I get the desired results in the app; however, the X in the top right corner stops working. How to I "reinstate" the close button ("X" in the top right hand corner) so it works again if pressed (and also evaluates the logic again). </p>
  
  <p>I tried this: <a href="https://stackoverflow.com/questions/3001525/how-to-override-default-window-close-operation">Stackoverflow Question</a></p>
  
  <p>i don't think I want to play with Visibility of the window. The window doesnt go anywhere. They have dirty data and they need to fix it or have it auto saved. </p>
  
  <p>What I have in the application is:</p>
  
  <pre><code>        private void DXWindow_Closing(object sender, CancelEventArgs e)
      {
  
          if (BtnPatSave.IsEnabled == false) return;
          if (MessageBox.Show(Properties.Resources.PatAcctMsgBox3, Properties.Resources.PatAcctMsgBox1,
                  MessageBoxButton.YesNo,
                  MessageBoxImage.Warning) == MessageBoxResult.No)
          {
              e.Cancel = true;
          }
          else
          {
              var patId = TbPatId.Text;
              var usl = new UnSetLockValue();
              usl.UnSetVal(patId);
              Log.Info("Patient Account is now unlocked by user: " + Environment.UserName);
          }
      }
  </code></pre>