WPF NotifyIcon气球未显示

本文关键字:显示 气球 NotifyIcon WPF | 更新日期: 2023-09-27 18:23:56

好吧,伙计们,对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);
    }

应该发生的是,当我关闭应用程序时,它会隐藏在系统托盘中(并且确实如此),但也应该弹出气球提示(并且没有)。

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

WPF NotifyIcon气球未显示

图标格式有一些限制,在对海报进行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);
}

工作正确,解决了气球未出现的问题。

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