Second Window
ViewModel
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Input;
using WpfApp1;
namespace WpfApp74
{
public class ViewModel : ICommand
{
public string ExeFileName { get; set; } // exe fullname from second window
public void Execute(object parameter)
{
switch (parameter.ToString())
{
case "Load": // show second window
var wnd = new Window74A(); // create second window
wnd.DataContext = this; // use the same instance as DataContext in second window
wnd.ShowDialog();
break;
case "Execute": // execute exe recorded in text box in second window
try { Process.Start(ExeFileName); }
catch (Exception ex) { MessageBox.Show(ex.Message); }
break;
default:
break;
}
}
public event EventHandler CanExecuteChanged;
public bool CanExecute(object parameter) => true;
}
}