Reputation: 124
I want to run wpf application with custom parameters in command prompt, basically this is achieve with no gui, if i don't run from command prompt, it should show gui!
Upvotes: 2
Views: 1319
Reputation: 291
Do this-
1) Add event -> Startup="App_Startup" to App.Xaml
2) Add Event handler for "App_Startup" to App.Xaml.cs
3) In "App_Startup" you can check command params this way-
if (e.Args.Length == 0)
{
MainWindow m = new MainWindow();
m.Show();
}
4) Remove StartupUri from App.Xaml
This way WPF GUI will appear only if there is no command args.
Upvotes: 3