2014-09-22 50 views
0

好吧,對於C#來說很新,但我還是很喜歡它。WPF NotifyIcon氣球沒有出現

我有一個應用程序最小化到系統托盤,我使用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(並且不) 。

任何想法;我很難過? :(

+0

嘗試使用'隱藏的()''而不是關閉()' – 2014-09-22 10:28:39

+0

此。關閉()阻止它形成提示 – Pavenhimself 2014-09-22 10:29:22

+0

它與隱藏/關閉功能無關 - 氣球在其他功能中也不起作用。 – 2014-09-22 10:34:03

回答

2

有上圖標格式一些限制並且成就與海報的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); 
} 

工作正常,並解決了氣球的問題沒有出現。

+0

太多了,噢,我的上帝。 – 2014-09-22 19:40:05

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

退房此鏈接:http://www.techotopia.com/index.php/Hiding_and_Showing_Forms_in_C_Sharp

+0

它與隱藏/關閉功能無關 - 氣球在其他功能中也不起作用。 – 2014-09-22 10:34:31

+0

這聽起來像你最好使用BeginInvoke(),所以只需爲這個特殊情況啓動另一個線程。 – deafjeff 2014-09-22 10:44:29

+0

@deafjeff您的評論根本不清楚。在什麼情況下調用'BeginInvoke'?如果它是一個UI元素,一個新的線程顯然不會被使用。 – 2014-09-22 10:51:59