Mahhala (isiZulu word for free or without charge) is a new series that showcase some of the cool free WPF/Silverlight controls available…
“You can learn a lot by reading other people's source code. That's the idea behind this series, "The Weekly Source Code." You can certainly become a better programmer by writing code but I think good writers become better by reading as much as they can.” - Scott Hanselman
This week I am very fortunate to be chatting with Philipp Sumi, the creator of WPF NotifyIcon
License: The Code Project Open License (CPOL) 1.02
RG - Welcome Philipp, please tell us a little about yourself?
PS - I'm a developer/architect/geek without work/life balance, a (yet) unofficially diagnosed code addiction and great love for all things .NET. I'm working as a freelancer and consultant in Switzerland and dream of spending European winter months creating cool software in sunny New Zealand or Australia (hint hint).
RG - What is WPF NotifyIcon?
PS - At its core, it's basically a wrapper around the Win32 API that enables you to display a NotifyIcon in the system tray area. However, it goes quite a bit beyond that core functionality by bringing WPF into the picture. Besides the tray icon, the developer can easily display rich tool tips, interactive popups, context menus or balloon messages in the tray area. All that functionality is exposed through a convenient API that should feel familiar for every WPF developer.
I came up with the control because I wanted to provide a rich user experience for a tool (NetDrives) that was supposed to run mainly in the background, but allows the user to quickly access some core functionality through the system tray. The existing WinForms component was too limited for my needs, so I wrote my own.
RG - How does you implementation compare with what is available in the new SL4 toast messages?
PS - Besides the different platforms (SL vs. WPF), Silverlight's toasts are basically a simple version of what's called a "balloon message" in the WPF control. You don't get all the other good stuff.
RG - Where can people get hold of you?
PS - Placing bear traps in front of big computer screens has proven to be quite a successful strategy. For the more subtle, there's a contact form on my blog (http://www.hardcodet.net/contact) that should produce a near-immediate (although less vocal) response as well.
Although I use WPF NotifyIcon 90% of the time for balloon popups, the more compelling scenario is when you use WPF content inside the balloon or popup…
“Unlike a ToolTip, a Popup is only displayed if the user clicks on the NotifyIcon. It stays open if the user moves the mouse away from the tray area, but will close as soon as the user clicks somewhere else. Accordingly, you can provide interactive content within a Popup, usually to provide some quick access to your application.”
<Border Background="#FAFFFFFF" Width="200" Height="75"
<RowDefinition Height="30" />
<RowDefinition Height="*" />
<RowDefinition Height="10" />
<Border Background="Blue" CornerRadius="5,5,0,0" Grid.Row="0" />
<Border Background="Blue" CornerRadius="0,0,5,5" Grid.Row="2" />
<TextBlock Text="WPF NotifyIcon" Foreground="White" Grid.Row="0" HorizontalAlignment="Left"
VerticalAlignment="Center" Margin="5,0,0,0" FontWeight="Bold">
<TextBlock Text="Very cool, huh?" Grid.Row="1" HorizontalAlignment="Left"
VerticalAlignment="Center" Margin="5,0,0,0" />
And here is how it looks…
For more information, read this cool CodeProject article and for a practical example of using WPF NotifyIcon in a PRISM/MVVM application, check out OpenPOS!
Next week I chat with Pavan Podila, the creator of FluidKit
Mahhala – AvalonDock
Mahhala – Fluent Ribbon Control Suite
Mahhala – Bag o' Tricks