I am going to stering my WPF program by external parameter - when the program is call.
In App.xaml.cs I added Startup code and remove StartupUri="MainWindow.xaml"
private void Application_Startup(object sender, StartupEventArgs e)
{
// Create main application window, starting minimized if specified
//StartupUri="MainWindow.xaml"
String[] arguments = Environment.GetCommandLineArgs();
MessageBox.Show(arguments[1]);
if (arguments[1] == "Window1")
{
Window1 mainWindow = new Window1();
mainWindow.Show();
}
if (arguments[1] == "Window2")
{
Window2 mainWindow = new Window2();
mainWindow.Show();
}
}
I worried, because this Application_Startup method is not fired.
Can any one want to help me?
The access modifier(private void) could be the problem. Instead try the below.
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
//your code
}