WPF NotifyIcon

November 24th, 2013

 

Version 1.0.5 released Nov 23th. (v1.1 is on the way – come back soon!)

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

 

Download Control & Sample Application
 

Download via NuGet

(Latest release: 1.0.5, 2013.11.23)

 

 

 

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. Vinod
    June 4th, 2013 at 09:10 | #1

    @Jordan Morris
    How can you have keyboard shortcuts on the NotifyIconWPF ContextMenu

  2. Juliano Soares
    June 18th, 2013 at 19:55 | #2

    Hi,
    Firstly, I would like to thank and congratulate the NotifyIcon.
    I have a WPF application with an inherited form of another class. This other class is not a form, but inherits from the Window class.
    Could use your component to display the icon on tray. But to display the popup window, I am getting an exception.
    This exception is occurring in this line “popup.Child = balloon;” (line 200), in a class TaskbarIcon. Can you help me with this?

  3. June 26th, 2013 at 19:30 | #3

    Great product.
    Feature request; can I specify the timespan for which to close the Balloon? It appears to be fixed at 60s.

    Cheers!

  4. Daniel
    July 7th, 2013 at 17:59 | #4

    I’m trying to use the TaskbarIcon in a console application which starts only as this icon. I tried creating the object in C# code, by creating a new class with the STAThread-attribute, and instantiating the TaskbarIcon in there. Like so:

    // create the system tray icon
    TaskbarIcon sysTrayIcon = new TaskbarIcon();
    sysTrayIcon.Icon = myIcon;
    sysTrayIcon.ToolTipText = “Tooltip”;
    ContextMenu menu = new ContextMenu();
    MenuItem item = new MenuItem { Header = “Close” };
    item.Click += (s, e) => { Debug.WriteLine(“Clicked!”); };
    menu.Items.Add(item);
    sysTrayIcon.ContextMenu = menu;

    Neither does the tooltip show up, nor does the context menu. If I click around on it, the tooltip or the context menu will appear randomly, but will not disappear and not react. It disappears when I close the application.
    So I looked into your sample project, how you’re creating the TaskbarIcon in code. The only place where you actually do that is in the Forms sample. I did it exactly like you did in there, and it still didn’t work. However, when executing the same code in a Windows Forms application, for example in the constructor of the main window, it works as it should.

    Do you (or anyone else) know why this is happening, and how I can fix it?

  5. There seem to be an issue in method Dispose of WindowMessageSink.
    July 25th, 2013 at 07:42 | #5

    Current implementation as follows,
    private void Dispose(bool disposing)
    {
    //don’t do anything if the component is already disposed
    if (IsDisposed || !disposing) return;
    IsDisposed = true;

    WinApi.DestroyWindow(MessageWindowHandle);
    messageHandler = null;
    }
    Since the window handle is unmanaged resource, it cannot be reclaimed by garbage collector automatically. Assume that you have forgotten invoking public Displose() method, GC will invoke Dispose(false). As a result the hidden window will still be alive. It is because “if (IsDisposed || !disposing) return;” has returned ahead of time. The correct implementation is as below:
    private void Dispose(bool disposing)
    {
    //You can lock the following codes if thread safety is necessary.
    if (!IsDisposed)
    {
    if (disposing)
    {
    // Release all the unmanaged resources namely
    // all the members that are intances of managed classes implementing IDisposable interface)
    // For this classs, there are no such members. Therefore do nothing.
    }

    WinApi.DestroyWindow(MessageWindowHandle);
    messageHandler = null;

    IsDisposed = true;
    }
    }

  6. dj.y.noter
    July 25th, 2013 at 07:44 | #6

    There seem to be an issue in method Dispose of WindowMessageSink. Current implementation as follows,
    private void Dispose(bool disposing)
    {
    //don’t do anything if the component is already disposed
    if (IsDisposed || !disposing) return;
    IsDisposed = true;

    WinApi.DestroyWindow(MessageWindowHandle);
    messageHandler = null;
    }
    Since the window handle is unmanaged resource, it cannot be reclaimed by garbage collector automatically. Assume that you have forgotten invoking public Displose() method, GC will invoke Dispose(false). As a result the hidden window will still be alive. It is because “if (IsDisposed || !disposing) return;” has returned ahead of time. The correct implementation is as below:
    private void Dispose(bool disposing)
    {
    //You can lock the following codes if thread safety is necessary.
    if (!IsDisposed)
    {
    if (disposing)
    {
    // Release all the unmanaged resources namely
    // all the members that are intances of managed classes implementing IDisposable interface)
    // For this classs, there are no such members. Therefore do nothing.
    }

    WinApi.DestroyWindow(MessageWindowHandle);
    messageHandler = null;

    IsDisposed = true;
    }
    }

  7. dj.y.noter
    July 25th, 2013 at 07:46 | #7

    There seem to be an issue in method Dispose of WindowMessageSink. Current implementation as follows,
    private void Dispose(bool disposing)
    {
    //don’t do anything if the component is already disposed
    if (IsDisposed || !disposing) return;
    IsDisposed = true;

    WinApi.DestroyWindow(MessageWindowHandle);
    messageHandler = null;
    }
    Since the window handle is a unmanaged resource, it cannot be reclaimed by garbage collector automatically. Assume that you have forgotten to invoke public Displose() method, GC will invoke Dispose(false). As a result the hidden window will still be alive. It is because “if (IsDisposed || !disposing) return;” has returned ahead of time. The correct implementation is as below:
    private void Dispose(bool disposing)
    {
    //You can lock the following codes if thread safety is necessary.
    if (!IsDisposed)
    {
    if (disposing)
    {
    // Release all the unmanaged resources namely
    // all the members that are intances of managed classes implementing IDisposable interface)
    // For this classs, there are no such members. Therefore do nothing.
    }

    WinApi.DestroyWindow(MessageWindowHandle);
    messageHandler = null;

    IsDisposed = true;
    }
    }

  8. dj.y.noter
    July 25th, 2013 at 07:48 | #8

    typo for@dj.y.noter . “Assume that you have forgotten invoking public Displose() method,” should be “Assume that you have forgotten to invoke public Displose() method, ”

    Sorry for repeated comments

  9. July 31st, 2013 at 00:37 | #9

    Upon targeting .Net 4 / 4.5, the sample app would generate an exception as the call to CreateWindowEx on line 190 of the WindowMessageSink.cs.

    Commenting out the null ptr check would allow the code to function, and the icon to display, but it would disappear on mouse over or other interaction.

    I’ve determined the cause was rooted in manually creating a window, the WndProc function must respond to the WM_NCCREATE message by returning TRUE. If it does not, the creation process will fail. In the current code, the message is passed to DefWindowProc which ought to return a value of 1, but does not.

    The corrective fix I’ve made, that works for all .NET version 3.5 to 4.5 is to check to determine if the messageId passed to OnWindowMessageReceived is equal to 0×0081 (129 dec), and if so, return a 1 after calling DefWindow Proc as follows:

    in WindowMessageSink.cs I’ve added

    public const int WmNCCreate = 0×0081;

    and modified OnWindowMessageReceived to read:

    private long OnWindowMessageReceived(IntPtr hwnd, uint messageId, uint wparam, uint lparam)
    {
    if (messageId == taskbarRestartMessageId)
    {
    //recreate the icon if the taskbar was restarted (e.g. due to Win Explorer shutdown)
    TaskbarCreated();
    }

    //forward message
    ProcessWindowMessage(messageId, wparam, lparam);

    // Pass the message to the default window procedure
    long result = WinApi.DefWindowProc(hwnd, messageId, wparam, lparam);
    result = messageId == WmNCCreate ? 1 : result;
    return result;
    }

    The call to CreateWindowEx now receives a valid ptr.

  10. Amir
    August 7th, 2013 at 19:55 | #10

    Can you please update the nuGet package after making a change to the assemblyinfo.cs

    [assembly: CLSCompliant(true)]

    My company policy is that all assemblies are CLSCompliant and this would make it cleaner for me rather than to download source and do it myself.

  11. Amir
    August 7th, 2013 at 19:57 | #11

    What about maybe adding a strong name to the nuget package too?
    I have a strong named application and I need to use reflection to load your DLL as strong named applications must only reference strong named libraries.

    Thanks

  12. Some Dude
    August 13th, 2013 at 18:37 | #12

    @P.Vilevac

    Thanks that fixed my problem :D

  13. jd
    August 29th, 2013 at 09:46 | #13

    I would also be very interested in knowing whether this component is going to be available for .NET 4+ and x64 platforms. Having to compile some applications in x86 just for this component makes me feel kind of old fashioned… Anyone has clues or know anything about the future of this component?

  14. October 4th, 2013 at 13:29 | #14

    I am using your solution in an MVVM app, working great. I would like the trayicon to pop up a balloon without the user having to click on or hover over it. I can’t see a property that exposes show pop up balloon. Am i doing it wrong, is there a better way to do this, I am using MVVM so tb.ShowBalloonTip doesn’t really work.

  15. prat
    October 16th, 2013 at 14:13 | #15

    @P.Vilevac That fixes the issue at startup but while bringing up the context menu the app still crashes. Observing this behavious on x64 machines and Windows 8

  16. Tony Vaughan
    October 17th, 2013 at 19:47 | #16

    @P.Vilevac
    Hello

    I tried your suggested change after NotifyIcon stopped working after using .NET 4.5. However, when I right-click on the taskbar icon, the application crashes with the message:

    Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

    HResult is -2147467261.

    Any idea what might be causing this?

    Thank you in advance.

  17. Tony Vaughan
    October 17th, 2013 at 20:08 | #17

    @P.Vilevac
    Sorry. Forgot to say that the app crashed at the following line:

    long result = WinApi.DefWindowProc(hwnd, messageId, wparam, lparam);

    Hope that helps.

  18. Tony Vaughan
    October 17th, 2013 at 21:02 | #18

    @prat
    I’m loading VS 2013 to see if that helps identify the problem better than 2012.

    I am also running x64 Windows 8.

    I’ll let you know how that goes.

  19. Tony Vaughan
    October 21st, 2013 at 20:35 | #19

    @P.Vilevac
    I loaded VS 2013 and it didn’t really help. I think the issue is that WinApi.DefWindowProc is called many times and somewhere on the way, when the notify icon is right-clicked, memory gets corrupted but I can’t see what exactly is corrupted (debug has apparently valid values in the standard patrameters). I am not a C++ developer and don’t know where to go from here. The only thing I can see that might help is that an extra message says:

    A first chance exception of type ‘System.AccessViolationException’ occurred in TaskbarNotification.dll

    followed by

    Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

    I would really appreciated any help that anyone can offer, because I fear I will have to abandon using NotifyIcon for .NET 4.5 forward, and I really love it.

  20. Tony Vaughan
    October 23rd, 2013 at 20:40 | #20

    @Mark Junker
    Woopee! Thanks a million Mark.

    The rest of you may have missed it, because Mark’s contribution was marked (sorry, pun not intended) as a fix for AMD machines. It also has the benefit of fixing the .NET 4.5 and 4.5.1 issue. I suspected the issue was to do with data types for CreaWindowEx() parameters, because all of the C++ examples I have seen use different data types as well. So, I thought I would give it a go, and it worked.

    No need for all of the workarounds – the original code works but for Mark’s changes. A tribute to Philipp’s original work.

    Well done Mark. I don’t know how you figured it out, but good on you.

    Cheers, from a grateful coder – I was on the point of giving up.

    Tony

  21. Persi
    November 6th, 2013 at 10:31 | #21

    @Mark Junker @Tony Vaughan

    A really big thank you for your patch, and to philipp for their work.
    It would be great to include the patch in a new release version.

  22. j-j
    November 6th, 2013 at 12:38 | #22

    //Note: XAML is suggested for all but the simplest scenarios
    TaskbarIcon tbi = new TaskbarIcon();
    tbi.Icon = Resources.Error;
    tbi.ToolTipText = “hello world”;

    >> Error: The type or namespace name ‘TaskbarIcon’ could not be found (are you missing a using directive or an assembly reference?)

    How do i import the lib?

  23. Lynspitti
    November 13th, 2013 at 09:27 | #23

    Great Project, have really helped me out.
    But still have a major problem,
    Why does PreviewKeyDown, KeyDown or TextChanged never fire??
    Need it on a textbox in the ContextMenu for the TaskbarIcon.

    • November 19th, 2013 at 10:34 | #24

      Fixed in the new version. I’ll deploy that one soon. Please post back if this is currently a show-stopper for you.

  24. December 2nd, 2013 at 13:50 | #25

    Hi Philipp, amazing work.
    Have you tried using an animated GIF instead of a PNG, because the animation is not displayed.
    Thanks

    • December 3rd, 2013 at 14:38 | #26

      Hi Diego
      Could you elaborate please? There’s no animations in the Taskbar (those are icon (*.ico) files), and the animation in the sample is a WPF storyboard that just rotates the PNG image…

  25. Acorn
    January 13th, 2014 at 18:53 | #27

    Hi, thank you for NotifyIcon. It’s a great library.
    I’ve noticed that LeftClickCommand is invoked with a small delay after click on icon.
    In the same time there is no such delay for DoubleClickCommand.
    Although LeftClickCommand delay is small it is still noticable to users using the application.
    It would be great to include a fix for this small issue in your future release.

    Thanks

  26. Foxy Chen
    January 17th, 2014 at 07:20 | #28

    Foxy Chen :
    Hi Philipp, amazing work. thank you so much to share this to other people.
    I’m using it, but I’m not familiar with WPF.
    I want change the notifyicon at running time.
    Should I just need to change the IconSource ?
    How to change to different .ico.
    Can you give me a help? thanks so much.

    Sorry , I forgot to say
    I need to change the IconSource in Codebehind, how do I write in cs code ?

  27. Mark Junker
    January 27th, 2014 at 08:13 | #29

    Hi,
    I have a problem when my application (which uses this library) is run in a Citrix environment where no access to the application bar is available.

    The problem is that the call to GetSystemTaskBarPosition throws an exception (Interop/TrayInfo.cs, GetTrayLocation).

    Here is our preliminary workaround:

    var process = System.Diagnostics.Process.GetCurrentProcess();
    var hwndMain = process.MainWindowHandle;
    var screen = System.Windows.Forms.Screen.FromHandle(hwndMain);
    if (screen == null)
    throw new Exception(“Monitor for main window not found.”);
    return new Point { X = screen.WorkingArea.Right, Y = screen.WorkingArea.Bottom };

    As you can see, we just use the working area of the main monitor – which is our best guess…

    BTW: We just used the functionality from System.Windows.Forms, but this might inconvenient for you.

  28. Michel
    February 9th, 2014 at 16:15 | #30

    Hi!

    I’m trying to create an Click Once publish for my application but I’ve received an message that your assembly is not signed. Do you have an signed version? please?

    Error 8 Assembly generation failed — Referenced assembly ‘Hardcodet.Wpf.TaskbarNotification’ does not have a strong name

    Thank you.

    • April 14th, 2014 at 19:51 | #31

      Michel,
      The current version isn’t signed – this will make adoption harder for the vast majority of people who use it. I’d recommend you just sign a version yourself.
      Thanks, Philipp

  29. Jake Ginnivan
    February 10th, 2014 at 14:05 | #32

    It would be good to put the source for this up on GitHub for easy browsing?

  30. Spuriga
    February 17th, 2014 at 10:50 | #34

    Hi,

    I have a problem with my MVVM based WPF application.

    Everything works well except calling the ShowBalloonTip function.

    I have found this article:
    http://stackoverflow.com/questions/12501348/how-to-implement-notifyicon-in-mvvm-project

    …but I don’t want to configure the TaskbarIcon in the viewmodel code.

    Could you help me, or it is not possible?

    Thanks a lot!

    • April 14th, 2014 at 19:49 | #35

      Have a look in the samples – they should show you alternatives to configuring the NotifyIcon.

  31. Caroline Stepnowski
    February 18th, 2014 at 01:53 | #36

    Is there a way to have a custom balloon use BalloonFlags.RespectQuietTime?

    • April 14th, 2014 at 19:48 | #37

      Hi Caroline

      I’m not sure I’d implement this. I’ll think about it.

      Thanks,
      Philipp

  32. MichaB
    February 28th, 2014 at 08:20 | #38

    Hi
    i got an error when i start my program with this notifyicon via remote Connection (terminal Server).
    I use Version 1.0.4.0. Is there a bugfix or is it fixed in a newer Version?

    Thank you in advance
    Michael

  33. Hi i got the problem
    March 6th, 2014 at 16:34 | #39

    First of all thanks for lib, quite cool!
    But i have a problem at Windows 8.1 on changing icon, idea of program is when you click on tray icon, it do something and changing icon from green to red, then red to green… etc.

    changing like that:

    MainWindow w = new MainWindow();
    w.Tray1.Icon = new Icon(@”C:\red_light.ico”);

    it don’t change icon, its just create new icon in tray list near, and if you click 10 times on my icon, it’ll be 10 icons in list with different colors…

    what im have to do ? please email me if you can

  34. Sriram
    March 13th, 2014 at 00:00 | #40

    This is an awesome effort that has helped me in my project and also learning WPF application coding. You have an excellent coding style and also great documentation. I have a unique requirement where I need to do multiple balloon popups and I am not able to time the interval between balloon popups. For example, I have 15 or so events that I need to balloon a popup and while I am enumerating the events and doing the popups, they all come out one after the other and only the last one stays. Introducing any thread.sleep or dispatch timer does not help. Any advice is much appreciated.

  35. Rob Moran
    March 19th, 2014 at 14:00 | #41

    Awesome Control.

    It would be great if you could add a flag to optionally remove the check for double-click as this adds a noticeable delay to the single-click event. In this case, double-click would not work of course, but I feel this is of less importance.

    • April 14th, 2014 at 19:46 | #42

      Rob,

      This is a feature request I’ll be implementing with the upcoming version.

      Thanks, Philipp

  36. Jeff
    April 2nd, 2014 at 20:11 | #43

    Hi,
    Is there another way to create the xaml declaration xmlns:tb=”http://www.hardcodet.net/taskbar”?
    Can’t this be contained with-in the project?
    I have been burned before by web addresses just vanishing from the web.
    Sorry if this is a “Basic” question, but I have been at C# WPF development for only a couple of months. I still have some holes in .net development to fill in.

    Thanks

    • April 14th, 2014 at 19:46 | #44

      Jeff,

      That URI is just an identifier – it doesn’t have anything to do with the website being existent. So even if hardcodet.net went down, you wouldn’t have to worry :)

  37. Alexey
    April 14th, 2014 at 19:03 | #45

    Hi, please Help me

    This not work in a Timer Elapsed method

    void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
    {

    FancyBalloon balloon = new FancyBalloon();
    balloon.BalloonText = “blalblalbla”;

    //show balloon and close it after 4 seconds
    MyNotifyIcon.ShowCustomBalloon(balloon, PopupAnimation.Slide, 10000);

    }

    and the same code works fine in
    private void button3_Click(object sender, RoutedEventArgs e)
    {
    FancyBalloon balloon = new FancyBalloon();
    balloon.BalloonText = “blablalba”;

    //show balloon and close it after 4 seconds
    MyNotifyIcon.ShowCustomBalloon(balloon, PopupAnimation.Slide, 10000);
    }

    please help to solve this problem, it is very important to me ..

  38. Alexey
    April 14th, 2014 at 20:09 | #47

    No, it’s all in the main thread

  39. Julien
    April 28th, 2014 at 13:14 | #48

    I see that for taskbar popups, the default behavior when you mouse over the popup is to call taskbarIcon.ResetBalloonCloseTimer();

    but once moused over, the popup never closes. am i missing something?

  40. Dojo
    April 30th, 2014 at 09:53 | #49

    I have a menuitem in contextmenu for the trayicon.
    menuitem just shows a MessageBox when clicked.

    Problem is, MessageBox flashes and disappears very quickly.

    Why is this?

    Here is the basic code.

    using System;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;

    namespace ScreenGrabberV3.TrayIcon
    {
    public class CustomContextMenu
    {
    public ContextMenu MyContextMenu { get; set; }
    private MenuItem menuItem1 = new MenuItem();
    private MenuItem menuItem2 = new MenuItem();
    private MenuItem menuItem3 = new MenuItem();
    private MenuItem menuItem4 = new MenuItem();
    public CustomContextMenu()
    {
    MyContextMenu = new ContextMenu();

    menuItem1.Header = BuildItemContent(“Exit”, new BitmapImage(new Uri(“pack://application:,,,/Resources/surveillance.png”)));
    menuItem2.Header = BuildItemContent(“Show UI”, new BitmapImage(new Uri(“pack://application:,,,/Resources/surveillance.png”)));

    menuItem1.Click += menuItem1_Click;
    menuItem2.Click += menuItem2_Click;

    MyContextMenu.Items.Add(menuItem1);
    MyContextMenu.Items.Add(menuItem2);
    }

    private StackPanel BuildItemContent(string text, ImageSource image)
    {
    StackPanel stackPanel = new StackPanel {Orientation = Orientation.Horizontal};

    Image imageObj = new Image {Source = image, Margin = new Thickness(0,0,10,0)};
    Label labelObj = new Label {Content = text};

    stackPanel.Children.Add(imageObj);
    stackPanel.Children.Add(labelObj);

    return stackPanel;
    }

    static void menuItem1_Click(object sender, System.Windows.RoutedEventArgs e)
    {
    e.Handled = true;
    MessageBox.Show(“click”, “test” , MessageBoxButton.YesNo, MessageBoxImage.Asterisk);
    //messagebox flashes and disappears
    }

    void menuItem2_Click(object sender, RoutedEventArgs e)
    {
    e.Handled = true;
    MessageBox.Show(“hello”);
    //messagebox flashes and disappears
    }
    }
    }

  41. Dojo
    April 30th, 2014 at 10:13 | #50

    What does this mean?
    I keep seeing this even though i have a contextmenu appearing when clicked.
    Unhandled NotifyIcon message ID: 123

  42. Jens Schumacher
    May 4th, 2014 at 23:33 | #51

    any cahnce of a version in nuget with a strong name?

  43. ltguide
    May 12th, 2014 at 08:15 | #52

    Right now is there a better/recommended way to do this? Essentially what I’m doing is making the CustomBallon a modal dialog for the TrayPopup (Windowless).

    private void UserControl_Loaded(object sender, RoutedEventArgs e) {
    // make TrayPopup stay open and focus on THIS
    TaskbarIcon.GetParentTaskbarIcon(this).TrayPopupResolved.StaysOpen = true;
    WinApi.ActivatePopup(Parent);
    }

    private void OnBalloonClosing(object sender, RoutedEventArgs e) {
    // allow TrayPopup to close and send focus back to it
    Popup TrayPopupResolved = TaskbarIcon.GetParentTaskbarIcon(this).TrayPopupResolved;
    TrayPopupResolved.StaysOpen = false;
    WinApi.ActivatePopup(TrayPopupResolved);
    }

  44. ltguide
    May 14th, 2014 at 18:07 | #53

    responding to myself
    The only problem I have with this is if you click outside the CustomBalloon the TextBoxes become unfocused again. If you activate the NotifyIcon by, say, left clicking on it then focus will come back to the CustomBalloon. I can’t find an event to listen for that is able to call ActivatePopup([CustomBalloon]) when you click back inside the CustomBalloon.

  45. Vishu
    June 24th, 2014 at 11:46 | #54

    Hi,

    Thanks for the awesome article.
    I will need your help to tackle a situation that i’m facing currently.

    I’ve modified the usercontrol that’s rendered as a popup from your code to contain a datagrid in it which binds to database.

    Everything looks fine except one issue. The datagrid doesn’t seem to update itself after the popup is re-opened again. Meaning if there is a change in the data then it doesn’t reflects in the datagrid.

    Is there a way i can achieve it? I’ve tried using dependencyproperty as well but no luck!

    Please help!

    Thanks,
    Vishu

  46. July 25th, 2014 at 15:21 | #55

    Is there a way to use DynamicResource to change the language of NotifyIcon MenuItems? It doesn’t work as expected.

  47. July 25th, 2014 at 19:29 | #56

    Hi,
    great work!

    Just one thing: DynamicResource doesn’t work at runtime, so I can’t properly support internationalization because I need to restart the application every time I change the language to update MenuItems’ headers.

    Is there a workaround for this issue?

    Thanks.

  48. Bruce
    August 27th, 2014 at 12:56 | #57

    Thanks so much for this project. It worked wonderfully for me. Even though I only needed a very minimal amount of functionality, the features I saw in the demo opened up a lot of possibilities for my app that I had previously not considered.
    Well done!

Comment pages
1 2 3 4 452
  1. May 11th, 2009 at 13:45 | #1
  2. May 26th, 2009 at 18:13 | #2
  3. June 1st, 2009 at 00:52 | #3
  4. June 24th, 2009 at 18:37 | #4
  5. August 4th, 2009 at 06:13 | #5
  6. October 18th, 2009 at 11:00 | #6
  7. October 26th, 2009 at 23:43 | #7
  8. March 11th, 2010 at 17:18 | #8
  9. May 6th, 2010 at 21:18 | #9
  10. May 19th, 2010 at 12:44 | #10
  11. May 27th, 2010 at 14:26 | #11
  12. February 26th, 2011 at 20:07 | #12
  13. September 27th, 2011 at 07:25 | #13
  14. September 27th, 2011 at 07:29 | #14
  15. February 2nd, 2012 at 04:03 | #15
  16. April 28th, 2012 at 14:37 | #16
  17. June 27th, 2012 at 20:06 | #17
  18. November 21st, 2012 at 03:39 | #18
  19. September 3rd, 2013 at 02:02 | #19
  20. October 18th, 2013 at 10:35 | #20
  21. March 10th, 2014 at 10:13 | #21
  22. March 14th, 2014 at 13:57 | #22