title: Implementing ShowDialog which is work in the same thread
body: <p>I am developing a WPF application and i want to show Dialogs in the active Window using a PopUp or a Different grid (by changing ZIndex in this grid). </p>
  
  <p>currently my solution works using Event and Event Handlers: </p>
  
  <pre><code> public static void ShowDialog(IDialog DialogControl)
   {
       // Get Active Window ...
       CurrentWindow = Application.Current.Windows.OfType&lt;Window&gt;().SingleOrDefault(x =&gt; x.IsActive);
       CurrentContent = (UIElement)CurrentWindow.Content;
       CurrentWindow.Content = null;
       CurrentContent.IsEnabled = false;     
  
       Grid DialogGrid = new Grid();
       Panel.SetZIndex(DialogGrid, 1);
       // ... 
       var Dialog = DialogControl.GetUserControl();
  
       DialogGrid.Children.Add(Dialog);
  
       DialogControl.OnDialogComplete += (object sender, DialogResult result) =&gt; { RestoreWindow(); OnDialogComplete?.Invoke(sender, result); };
  
       CurrentWindow.Content = DialogGrid;
   }
  
   interface IDialog
   {
       UserControl GetUserControl();
       event DialogComplete OnDialogComplete;
   }
  </code></pre>
  
  <p>So, I'm using it in this way : </p>
  
  <pre><code> private void Button_Click(object sender, RoutedEventArgs e)
   {
       DialogCenter.OnDialogComplete += DialogCenter_OnDialogComplete;
       DialogCenter.ShowDialog(new Test());
   }
  
   private void DialogCenter_OnDialogComplete(object sender, DialogResult result)
   {
       // Take Result and Do something 
       DialogCenter.OnDialogComplete -= DialogCenter_OnDialogComplete;
   }
  </code></pre>
  
  <p>this is a ugly code and i don't want to make my codes more Complicated.
  i have tried to wait for DialogResult but this Dialog is in the same thread and waiting will blocks my execution. </p>
  
  <p>is there any way to do this work in a cleaner way ?</p>