【问题标题】:WPF NotifyIcon Balloon not showing upWPF NotifyIcon 气球未显示
【发布时间】:2014-09-22 10:22:27
【问题描述】:

好吧,伙计们,对 C# 还很陌生,但我已经开始使用它了。

我有一个最小化到系统托盘的应用程序,我正在使用WPF NotifyIcon 来执行此操作。我正在尝试使用内置的气泡提示功能。

虽然我没有遇到任何错误,但它似乎无法正常工作。

我的代码如下:

    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);
    }

应该发生的是,当我关闭应用程序时,它会隐藏到系统托盘(并且会),但也应该弹出 BalloonTip(并且不会)。

任何想法;我被难住了? :(

【问题讨论】:

  • 尝试使用Hide() 而不是Close()
  • This.Close() 防止它形成欺骗
  • 它与隐藏/关闭功能无关 - 气球在其他功能中也不起作用。
  • 你能发布更多代码吗
  • 什么?这是唯一的问题???

标签: c# wpf notifyicon balloon-tip


【解决方案1】:

图标格式存在一些限制,并且在与海报进行了 TeamViewer 会话后,我们得出的结论是是图标导致了问题。

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);
}

正常工作并解决了气球不出现的问题。

【讨论】:

  • 这么多,是的,天哪。
【解决方案2】:
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);
}

查看此链接:http://www.techotopia.com/index.php/Hiding_and_Showing_Forms_in_C_Sharp

【讨论】:

  • 它与隐藏/关闭功能无关 - 气球在其他功能中也不起作用。
  • 听起来你最好使用 BeginInvoke() 所以只为这种特殊情况启动另一个线程。
  • @deafjeff 您的评论根本不清楚。打电话给BeginInvoke 什么?如果它是一个 UI 元素,显然不会使用新线程。
猜你喜欢
  • 2015-01-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多