I have a WPF window in a project with a XAML file and the associated C # code behind the file. If I set "StartupUri = MainWindow.xaml" in App.xaml to this window, the window opens as expected when I launch the application.
However, I want my application to accept command line options, and then decide whether it should open the graphical interface or not. So instead, I set "Startup = Application_Startup" to my App.xaml file, which is defined as shown below.
private void Application_Startup(object sender, StartupEventArgs e) { if (e.Args.Length > 1) { //do automated tasks } else { //open ui MainWindow window = new MainWindow(); this.MainWindow = window; window.Show(); } }
However, when I run this, the displayed window is completely empty.

Eric Anastas
source share