0

Okay guys, quite new to C# but I'm getting on with it just fine.

I've got an application minimised to the system tray and I'm using WPF NotifyIcon to do this. I'm trying to use the built in bubble tip feature.

Whilst I've got no errors, it just doesn't seem to be working.

My code is as follows:

    private void OnTaskBarMenuItemExitClick(object sender, RoutedEventArgs e)
    {
        m_isExplicitClose = true;//Set this to unclock the Minimize on close 

        this.Close();

        string title = "WPF NotifyIcon";
        string text = "This is a standard balloon";

        TaskBar.ShowBalloonTip(title, text, Properties.Resources.Server);
    }

What should happen is that when I close the application, it hides to the system tray (and does) but should also popup the BalloonTip (and doesn't).

Any ideas; I'm stumped? :(

Tom Wilson
  • 253
  • 1
  • 7
  • 15

2 Answers2

3

There's some constraints on icon format and having done a TeamViewer session with the poster, we've come to the conclusion that it was the icon causing the issue.

private void OnTaskBarMenuItemExitClick(object sender, RoutedEventArgs e)
{
    m_isExplicitClose = true;//Set this to unclock the Minimize on close 

    this.Close();

    string title = "WPF NotifyIcon";
    string text = "This is a standard balloon";

    TaskBar.ShowBalloonTip(title, text, BalloonIcon.Error);
}

Worked correctly and resolved the issue of the balloon not appearing.

Ashley Davies
  • 1,873
  • 1
  • 23
  • 42
0
private void OnTaskBarMenuItemExitClick(object sender, RoutedEventArgs e)
{
    m_isExplicitClose = true;//Set this to unclock the Minimize on close 

    this.Hide();

    string title = "WPF NotifyIcon";
    string text = "This is a standard balloon";

    TaskBar.ShowBalloonTip(title, text, Properties.Resources.Server);
}

check out this link: http://www.techotopia.com/index.php/Hiding_and_Showing_Forms_in_C_Sharp

Pavenhimself
  • 527
  • 1
  • 5
  • 18
  • It has nothing to do with the hide/close function - the balloon doesn't work in other functions either. – Tom Wilson Sep 22 '14 at 10:34
  • It sounds like you better use BeginInvoke() so just start another thread for this special case. – deafjeff Sep 22 '14 at 10:44
  • @deafjeff Your comment is not clear at all. Call `BeginInvoke` on what? If it was a UI element a new thread obviously wouldn't be used. – Daniel Kelley Sep 22 '14 at 10:51