title: Embed a Window into Another
body: <p>I have two WPF applications which I wrote myself, App1 and App2. I wish to embed App2 into App1.</p>
  
  <p>Currently, I am trying this:</p>
  
  <pre><code>App2 app2 = new App2();
  object content = app2.Content; //which is a grid
  app2.Content = null;
  mainGridOfApp1.Children.Add(content as UIElement);
  </code></pre>
  
  <p>It does appear, but there's a few problems:</p>
  
  <ul>
  <li>It is not displayed correctly; the button locations and other UIElements are all messed up.</li>
  <li>It covers the entire screen, although mainGridOfApp2 is fixed at a much smaller size. The effect is like <code>WindowState.Maximized</code>.</li>
  <li>I have applied a custom style (theme) in App2, but since App2's App.xaml is not read, the custom style is not applied. How do I apply it?</li>
  </ul>
  
  <p>How do I embed App2 into App1 seamlessly? I do not want to start App2 as a separate process and setting App1 as the parent because that would mean it would always be on top of whatever UI component App1 have.</p>
  
  <p><strong>EDIT:</strong>
  I have embedded App2 into App1. I put the main grid of App2 into a <code>UserControl</code>, and loaded the <code>UserControl</code> from the Window. For App1's side, all I did was call the <code>UserControl</code> of App2 after referencing it.</p>