WPF NotifyIcon

April 2nd, 2016

 

Version 1.0.8 released April 2nd 2016.

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.

image

Browse/fork/clone Git repository (includes sample application)
Download library via NuGet

 

 

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.

quickaccess

 

image

 

image

 

image

 

image

 

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>
  1. Joerg
    October 29th, 2015 at 06:42 | #1

    Hello Philipp,

    is this project still alive? I have been waiting for 1.1 for a very long time. Version 1.0.5 produces access violations when I try to show an OpenFileDialog in my App. So I’ve been stuck on 1.0.4, which has some other weird issues sometimes.
    I also could not find the original repository on GitHub. Any ieda?

  2. andrew
    May 27th, 2016 at 18:09 | #2

    Very cool library that I just discovered. So lucky it was recently updated. Thanks for all your hard work on this!

  3. June 13th, 2016 at 19:27 | #3

    We are using this assembly in a 2015 WPF project .net 6.0 and everything has been working fine until we started to deploy using ClickOnce deployment. When we close the window we call the TaskbarIcon.ShowBalloonTip method to make the balloon appear and put an icon in the icon tray.

    However, when this is deployed with ClickOnce, everything still executes but the balloon does not popup. The app icon is still in the icon tray and behaves as expected.

    If I go to where the app is deployed and double click on the app’s exe everything will run as expected. If I make a shortcut to the app’s exe and use the shortcut to start the app – everything runs as expected. But when I click on the shortcut made by clickonce, the balloon fails to appear.

    Any advice on how to make this work in a ClickOnce installation?

    Thank you.

  4. June 14th, 2016 at 16:48 | #5

    @Philipp Sumi
    Hi Philip,

    Yes it could be related to that issue, but the link you provided listed a number of people with the same problem but offered no solution. Do you know of a fix or work around?

    Thank you.

  5. June 14th, 2016 at 16:52 | #6

    @George

    I’m afraid I don’t, sorry. If that part of the API is locked by Windows, there might not be a workaround. Can you revert to custom tooltips instead? They provide a richer user experience anyway…

  6. June 14th, 2016 at 17:04 | #7

    Thank you for the quick response Philipp.

    When we close the app’s window (wpf) a balloon pops up in the bottom right corner of the screen to notify the user that the app is still running in the background. are you saying it’s possible to make custom tooltips have the same behavior?

  7. June 14th, 2016 at 17:23 | #8

    Have a look at the sample app, which contains a sample with custom balloons. They allow you to display an arbitrary user control in the tray area.

  8. Paul
    September 25th, 2016 at 16:35 | #9

    Philipp, thank you for this great package. It is easy to use and looks beautifully. I am having trouble getting version 1.0.8 through nuget. If I select the package highlighted in the screenshot http://prnt.sc/cm6xib
    it installs into a folder that has 1.0.8 in the name, but right-clicking on the DLL and selecting Properties shows version 1.0.5.

    Also what is the SignedBuild package? Is there version 1.0.8 of the signed package?

    Thank you
    Paul

    • September 26th, 2016 at 07:35 | #10

      Paul, I just forgot to update the version number in AssemblyInfo.cs – the binaries are up-to-date, so don’t worry. I’ll fix this with the next version.

  9. Dojo
    November 22nd, 2016 at 23:38 | #11

    Thought i contribute to a great control;

    ICON FROM PNG RESOURCE

    StreamResourceInfo sri = GetResourceStream(new Uri(“pack://application:,,,/ScreenScraper;component/Resources/image.png”));
    if (sri != null)
    {
    Bitmap bmp = new Bitmap(sri.Stream);
    if (_notifyIcon != null) _notifyIcon.Icon = Icon.FromHandle(bmp.GetHicon());
    }

Comment pages
1 4 5 6 452
  1. No trackbacks yet.