如何从 Windows 窗体运行/调用 WPF 应用程序 (.exe)?我知道可以像下面这样完成:
Process.Start(@"C:\ABC\WPF.exe");
但我想从 winform 应用程序向 WPF 应用程序发送一些参数。怎么做?
最佳答案
引用 here 的完整代码
您可以从 winform 应用程序传递参数,例如
Process.Start(new ProcessStartInfo(@"C:\repos\WpfApp.exe", "WinForms 中的参数"));
并在 WPF 应用程序中接收,例如
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
if (e.Args.Length > 0)
{
MessageBox.Show($"You have passed:{e.Args.Length} arguments," +
$" value are {string.Join( ",",e.Args)}");
}
}
}
关于c# - 使用参数从 Winform 应用程序调用 WPF 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55667629/