Command-Line Arguments in a WPF Application
By Michael Detras
We can supply command-line arguments to our WPF application and access them in the Application's Startup event handler.
The following example shows an Application class that has a Startup event handler. We can access the command-line arguments using the StartupEventArgs.Args property, which is an array of strings.
public partial class App : Application
{
private void App_Startup(object sender, StartupEventArgs e)
{
var mainWindow = new MainWindow(e.Args[0]);
mainWindow.Show();
}
}
Command-Line Arguments in a WPF Application (1404 Views)