Start a WPF application in the notification area with Caliburn.Micro

Sometimes you’re writing a quick utility app that you wish to start directly in the notification area (near the clock), and not display anything on startup.
It’s actually very simple using Caliburn.Micro.

You probably already have customized your application bootstrapper already. All you have to do is modify the OnStartup  method from DisplayRootViewFor<T>  to displaying a custom tooltip. Here I’m using the Hardcodet.NotifyIcon.Wpf Nuget package:

It seems obvious in retrospect, but it took me a while to find this, because I don’t modify the app bootstrapper often, so I forgot about this method.

Don’t forget to add behavior to this icon! Double-click, context menu…

I have created a Caliburn.Micro + MahApps template app if you wish a starting point : https://github.com/cosmo0/Caliburn.MahApps.Metro.Template

  • Thierry

    Hello,
    Great project, this helps me a lot. I am new on wpf, i’m wondering how can you manage Navigation on your project ?
    Suppose we have a button on MainView to Navigate to another Page, like AnotherPageView, how can you manage this here ?
    Do you need to add a service like NavigationService ?

    • In the template, navigation is achieved like this :
      – Create another view and viewmodel like the MainViewModel (subscribe to the event aggregator)
      – In the viewmodel, in the method changing the screen, instantiate a new ChangeMainScreenEvent and set the Screen property to the instance of the screen you want to display.
      – Use the Publish method of the event aggregator to send the ChangeMainScreenEvent to all subscribers. The MasterViewModel will then change the active screen (see MasterViewModel.Handle(ChangeMainScreenEvent).

      All of this uses the concepts of event aggregator (http://caliburnmicro.com/documentation/event-aggregator) and screen conductors (http://caliburnmicro.com/documentation/composition). You can probably implement navigation in another way, but I like to use events like this.

      • Thierry

        Thanks for your reply. I will try this way, tonight.

      • Thierry

        Thank you very much @thomasbroust:disqus . I implement like you suggest, it works like a charm.