Within my WPF Application I use the "WPF NotifyIcon" (https://www.codeproject.com/Articles/36468/WPF-NotifyIcon-2) library to send OS Ballontips like this
TaskbarIcon tbi = new TaskbarIcon();
string title = "My title";
string text = "My texte...";
//show balloon with custom icon
tbi.ShowBalloonTip(title, text, NotifiyTest_01.Properties.Resources.Error);
This works fine but now I like to react on clicks on that Ballontip and open specific windows to guide the user. I found that the TaskbarIcon class implements an RoutedEventHandler named TrayBalloonTipClicked which is described as handler for Ballontips clicks.
Now I could not figure out how to react to such a click event. I am only used to events defined within XAML definitions like Click="Button_Click" where I just implement a method like this
private void Button_Click(object sender, RoutedEventArgs e)
{
}
Can anybody help? Thank you!
Thanks for your help, you gave me the perfect hints. Now this works fine:
private void BalloonTip_Clicked(object sender, RoutedEventArgs e)
{
//do it...
}
private void Button_Click(object sender, RoutedEventArgs e)
{
string title = "My title";
string text = "My texte...";
tbi.TrayBalloonTipClicked += new RoutedEventHandler(BalloonTip_Clicked);
//show balloon with custom icon
tbi.ShowBalloonTip(title, text, NotifiyTest_01.Properties.Resources.Error);
//hide balloon
tbi.HideBalloonTip();
}