WPF Application running from tray, how do I bring up a window in CM?

Topics: Bootstrappers & IoC, Getting Started, UI Architecture
Sep 28, 2011 at 1:13 AM

I'm not even sure if I'm taking even remotely the right approach here so some advice would be appreciated. Basically I have this application which needs to run in the tray 99% of the time, with just a little UI interaction which I'm using Caliburn.Micro for.

Essentially in the bootstrapper I'm overriding OnStartup where I build a System.Windows.Forms.NotifyIcon. The bootstrapper extends Bootstrapper<ShellViewModel>, and ShellViewModel and ShellView are both empty with ShellView visibility set to Hidden. This results in a tray icon but no visible window.

Now I need to respond to a context menu item click on the NotifyIcon by bringing up a different window, which I'll call SettingsView (obviously backed by a SettingsViewModel). How can I go about this from inside the bootstrapper, where I am handling this event? Is there a more sane way of doing this?


Sep 28, 2011 at 5:50 PM

I guess that using IWindowManager should work. You can get the instance of the WindowManager directly from the container (where you should also care to register it).

Sep 29, 2011 at 12:27 AM

IWindowManager did the trick, thanks!