Konstruktor MainWindow zostaje dwukrotnie wywołany

Próbuję ustawićDataContext zMainWindow do jego ViewModel wApp.OnStartup. Zauważyłem to robiąc toMainWindow() konstruktor jest wywoływany dwukrotnie i widzę 2 otwarte okna. Jakiś pomysł co powoduje to zachowanie? Mój kod jest następujący:

public partial class App : Application
{
    protected override void OnStartup(StartupEventArgs e)
    {
        base.OnStartup(e);

        MainWindow mainWindow = new MainWindow();

        // Create the ViewModel to which the main window binds.
        MainWindowViewModel mainWindowViewModel = new MainWindowViewModel();

        // Register handle such that when the mainWindowViewModel asks to be closed, close the window.
        mainWindowViewModel.RequestClose += delegate(System.Object o, System.EventArgs eventArgs)
        {
            mainWindow.Close();
        };


        mainWindow.DataContext = mainWindowViewModel;

        mainWindow.Show();
    }
}

questionAnswers(1)

yourAnswerToTheQuestion