July 2017
Beginner
466 pages
9h 37m
English
You can also pass command-line parameters to a WPF application. These will be captured in the Startup event of the App.xaml file. The StartupEventArgs e has a property named Args that returns the command-line parameters as an array of strings.
The following example demonstrates how to retrieve the command-line arguments in WPF application:
private void Application_Startup(object sender,
StartupEventArgs e)
{
var args = e.Args;
if (args != null && args.Count() > 0)
{
foreach (var arg in args)
{
// write code to use the command line arg value
}
}
}
You can go to the project properties by navigating to Debug | Command line arguments (as shown in the following screenshot) to set the arguments for debugging ...
Read now
Unlock full access