title: c# set main window after startup window
body: <p>If I start my application I start one custom window with 3 button's. Here is the <code>app.xaml</code> Code:</p>
  
  <pre><code>&lt;Application x:Class="EbayManager.App"
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
           Startup="ApplicationStart"&gt;
  &lt;/Application&gt;
  </code></pre>
  
  <p>Here is the <code>app.xaml.cs</code> Code:</p>
  
  <pre><code>    private void ApplicationStart(object sender, StartupEventArgs e)
      {
          Current.ShutdownMode = ShutdownMode.OnExplicitShutdown;
  
          ChooseAccountWindow chooseAccountWindow = new ChooseAccountWindow();
          chooseAccountWindow.ShowDialog();
  
          MainWindow mainWindow = new MainWindow(chooseAccountWindow.Result);
          mainWindow.Show();
      }
  </code></pre>
  
  <p>The <code>ChooseAccountWindow</code> have 3 button's here is the <code>CustomAccountWindow.xaml.cs</code> Code:</p>
  
  <pre><code>public partial class ChooseAccountWindow : MetroWindow
  {
  
      public string Result { get; set; }
  
      public ChooseAccountWindow()
      {
          InitializeComponent();
      }
  
      private void btnDastaschentuch2013_Click(object sender, RoutedEventArgs e)
      {
          this.Result = "dastaschentuch2013";
          this.Close();
      }
  
      private void btnSkeptar_de_Click(object sender, RoutedEventArgs e)
      {
          this.Result = "skeptar_de";
          this.Close();
      }
  
      private void btnAsdf_de_Click(object sender, RoutedEventArgs e)
      {
          this.Result = "asdf_de";
          this.Close();
      }
  
  
  }
  </code></pre>
  
  <p>The <code>ChooseAccountWindow.xaml</code> should be an second window, and the main window should be the <code>MainWindow.xaml</code>. After pressing a button I want, that the second window <code>ChooseAccountWindow.xaml</code> will closed &amp; the main window should be displayed. Is that the correct way? Because this two commands:</p>
  
  <pre><code>MainWindow mainWindow = new MainWindow(chooseAccountWindow.Result);
  mainWindow.Show();
  </code></pre>
  
  <p>open the main window, but the title isn't displayed and I cant set the height &amp; width of the window. </p>
  
  <p>Here is the <code>MainWindow.xaml</code> Code:</p>
  
  <pre><code>&lt;Controls:MetroWindow x:Class="EbayManager.MainWindow"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
      Title="MainWindow" Height="3500" Width="525" GlowBrush="{StaticResource AccentColorBrush}"&gt;
  &lt;Grid&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p></p>
  
  <p>Here is the Code of the <code>MainWindow.xaml.cs</code></p>
  
  <pre><code>namespace EbayManager
  {
  public partial class MainWindow : MetroWindow
  {
      private string p;
  
      public MainWindow()
      {
          InitializeComponent();
      }
  
      public MainWindow(string p)
      {
          // TODO: Complete member initialization
          this.p = p;
          MessageBox.Show(p);
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Maybe someone of you can help me.</p>