title: Set DialogResult without closing the Dialog
body: <p>As the title says, Is there anyway to set DialogResult without closing a Dialog?</p>
  
  <p>Probably the easy answer is NO, but even though, Why is that? What is the behaviour behind <code>DialogResult=</code> ? Is there any way to override it.</p>
  
  <p>For anyone who asks, why I even need something like this, the simple answer is curiosity. The 'history' behind this curiosity is that I am trying to call dialog windows from my ViewModel.My approach is a mixture of the following</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/a/13673795/2279200">WPF Open a new View from the ViewModel (linked answer)</a></li>
  <li><a href="http://www.codeproject.com/Articles/820324/Implementing-Dialog-Boxes-in-MVVM" rel="nofollow noreferrer">Implementing Dialog Boxes in MVVM</a></li>
  </ul>
  
  <p>In cases that the dialog has a return value (True (Ok) / False (Cancel)), I need to pass (from dialog viewModel) that value the class that handles the Dialogs and then set it as the <code>DialogResult</code> in order for the parent window / control to get it when the dialog returns / closes.</p>
  
  <p>The a minimal code snippet to test it, is something like</p>
  
  <pre><code>dialog.DialogResult = TheResult;
  Debug.WriteLine("Dialog Closed");
  dialog.Close();
  </code></pre>
  
  <p>While this does not fail, the dialog closes, when the "Dialog Closed" is printed to the Output, before calling <code>dialog.Close();</code>. If I override the <code>Window.Closing</code> event, I can see it firing when calling <code>dialog.DialogResult</code> but not when the <code>dialog.Close();</code> gets called afterwards.</p>
  
  <p>Note: As I said the whole question is 'out of curiosity' since the code above works and does not harm the desirable functionality.</p>