I am opening a WPF window from a tray app. I use the following code to open the window:
if (gui == null)
{
gui = new App();
You should try out the Closing event. This article provides useful information about when a WPF is actually closing (not just the window).
Josh was able to give the correct solution. You can see his answer here.
Basically, I needed to start the WPF as a separate process, and then use the MyProcess.WaitForEnd() call. I added this to a thread so it wouldn't block the Tray. The code is as follows:
Process myProcess = new Process();
myProcess.StartInfo.UseShellExecute = false;
myProcess.StartInfo.FileName = "C:\\mysettingsapp\\mysettingsapp.exe"; // replace with path to your settings app
myProcess.StartInfo.CreateNoWindow = false;
myProcess.Start();
// the process is started, now wait for it to finish
myProcess.WaitForExit(); // use WaitForExit(int) to establish a timeout