WPF NotifyIcon
This is an implementation of a NotifyIcon (aka system tray icon or taskbar icon) for the WPF platform. It does not just rely on the Windows Forms NotifyIcon component, but is a purely independent control which leverages several features of the WPF framework in order to display rich ToolTips, Popups, context menus, and balloon messages. It can be used directly in code or embedded in any XAML file.

Download Control & Sample Application
(Latest release: 1.0.4, 2009.09.22)
Features at a glance
- Custom Popups (interactive controls) on mouse clicks.
- Customized ToolTips (Vista and above) with fallback mechanism for xp/2003.
- Rich event model including attached events to trigger animations in Popups, ToolTips, and balloon messages. I just love that.
- Full support for standard Windows balloons, including custom icons.
- Custom balloons that pop up in the tray area. Go wild with styles and animations
- Support for WPF context menus.
- You can define whether to show Popups on left-, right-, double-clicks etc. The same goes for context menus.
- Simple data binding for Popups, ToolTips and custom balloons through attached properties and derived data context.
- Command support for single / double clicks on the tray icon.
Tutorial and Support
- A comprehensive tutorial that complements the attached sample application can be found on the Code Project:
http://www.codeproject.com/KB/WPF/wpf_notifyicon.aspx
Please post support questions to the CodeProject forum only. Thank you.
Screenshots
The screenshots below were taken from NetDrives and the sample application.





XAML Declaration Sample
The sample below shows some of the properties of the control. For a more comprehensive sample, have a look at the sample application that comes with the download.
<Window x:Class="Hardcodet.NetDrives.UI.SystemTray.Sample" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:tb="http://www.hardcodet.net/taskbar"> <tb:TaskbarIcon x:Name="myNotifyIcon" Visibility="Visible" ToolTipText="Fallback ToolTip for Windows xp" IconSource="/Images/TrayIcons/Logo.ico" ContextMenu="{StaticResource TrayMenu}" MenuActivation="LeftOrRightClick" TrayPopup="{StaticResoure TrayStatusPopup}" PopupActivation="DoubleClick" TrayToolTip="{StaticResource TrayToolTip}" /> </Window>
Great stuff.
Can you explain how I use this to do something like:
- user drags files or folders onto the trayicon
- usercontrol pops up and user can drop the files onto the usercontrol
I do not seem to find how to wire up the drag over / drop events …
Are you planning to put this somewhere like codeplex? It would be great as we could then hook into codeplex source control so we can always keep in sync with the latest.
Thanks
David,
No, the control is a part of my own repository, so I’ll keep the sources here. However, if you want to keep up-to-date, you can subscribe to the blog’s feed - I’m announcing all updates here.
Cheers,
Philipp
Hi,
This is great but have you considered how to show multiple balloons? I have a scenario where one baloon may be showing and another baloon is requested?
Hi Phillip,
Just wanted to say congrats on a great piece of code! Thanks for sharing it
Neal
Hi,
Is this sample code availible in vb?
Regards,
@Sam
Sam, there is actually a way to keep the balloon open. Have a look at the CloseBalloon method in the control. You will see that if the BalloonClosing event is being handled (setting the Handled property of the method to true), the popup is *not* being closed.
@Neal Hudson
Thanks for your kind words. Happy coding
@Jacobus
C# only, I’m afraid. However, you could open the compiled sample in Reflector, which can also decompile the code to VB, I think. For snippets, you could still use a C#->VB converter. There are a few of them on the net where you can just convert C# code on the fly to VB.NET.
@Bart Roelant
Bart,
I would have to find out how to DND onto the tray myself. Keep in mind that the tray icon itself is not a WPF or .NET component - this is pure Windows API. You will have to search the WWW into that direction.
@Philipp Sumi
This sounds like a mission. I think it would be easier just to do the project over in C#.
Thanx for the quick response.
@Jacobus
Just in case you don’t know yet: You can easily use the compiled (C#) assembly in a VB project.
Simple question: how to use the notify icon without putting this into the window.
My use case - only what I have is the application.
@RS
You can easily declare the control in code:
License?
@arj
CodeProject Open License (CPOL)