WPF Application that only has a tray icon
Asked Answered
D

3

166

I am a total WPF newbie and wonder if anyone could give me some pointers how to write an application that starts minimized to tray. The idea is that it periodically fetches an RSS Feed and creates a Toaster-Popup when there are new feeds.

The Application should still have a Main Window (essentially just a list containing all feed entries), but that should be hidden by default.

I have started reading about XAML and WPF and I know that the StartupUri in the App.xaml has to point to my main window, but I have no idea what the proper way is to do the SysTray icon and hide the main window (this also means that when the user minimizes the window, it should minimize to tray, not to taskbar).

Any hints?

Dynasty answered 24/9, 2009 at 15:59 Comment(0)
D
127

There's no NotifyIcon for WPF.

A colleague of mine used this freely available library to good effect:

Dennard answered 24/9, 2009 at 16:3 Comment(4)
Drew, the link appears to have gone dead here. Do you have an alternative link for this library? I did a quick search, but couldn't determine if the results were for the same project.Eighteenmo
@BradLarson, the site seems to be down; but anyway the project is available as Nuget package (see Dale's answer)Jameejamel
The large number of votes notwithstanding, this answer does not constitute a useful, legitimate Stack Overflow answer. It is effectively a link-only answer, contrary to Stack Overflow standards. Please improve this answer by providing the specific, material information in the answer itself. This will ensure the information is available regardless of the status of the external site.Pharynx
And the picture also has no source attribution (was taken from the website), which also violates the guidelines.Neral
B
55

I recently had this same problem. Unfortunately, NotifyIcon is only a Windows.Forms control at the moment, if you want to use it you are going to have to include that part of the framework. I guess that depends how much of a WPF purist you are.

If you want a quick and easy way of getting started check out this WPF NotifyIcon control on the Code Project which does not rely on the WinForms NotifyIcon at all. A more recent version seems to be available on the author's website and as a NuGet package. This seems like the best and cleanest way to me so far.

  • Rich ToolTips rather than text
  • WPF context menus and popups
  • Command support and routed events
  • Flexible data binding
  • Rich balloon messages rather than the default messages provides by the OS

Check it out. It comes with an amazing sample app too, very easy to use, and you can have great looking Windows Live Messenger style WPF popups, tooltips, and context menus. Perfect for displaying an RSS feed, I am using it for a similar purpose.

Beltran answered 24/9, 2009 at 16:8 Comment(0)
T
1

Simplest way that work, use the NotifyIcon from System.Windows.Forms.

Tartuffery answered 7/1 at 15:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.