Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/266.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#WPF NotifyIcon BalloodTip和TrayBalloonTipClicked事件_C#_Wpf_Eventhandler_Notifyicon - Fatal编程技术网

C#WPF NotifyIcon BalloodTip和TrayBalloonTipClicked事件

C#WPF NotifyIcon BalloodTip和TrayBalloonTipClicked事件,c#,wpf,eventhandler,notifyicon,C#,Wpf,Eventhandler,Notifyicon,在我的WPF应用程序中,我使用“WPF NotifyIcon”(WPF NotifyIcon)库发送操作系统气球,如下所示 TaskbarIcon tbi = new TaskbarIcon(); string title = "My title"; string text = "My texte..."; //show balloon with custom icon tbi.ShowBalloonTip(title, text, NotifiyTest_01.Properties.Res

在我的WPF应用程序中,我使用“WPF NotifyIcon”(WPF NotifyIcon)库发送操作系统气球,如下所示

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);
private void Button_Click(object sender, RoutedEventArgs e)
{
}
这很好,但现在我喜欢在点击气球时做出反应,打开特定的窗口来引导用户。我发现TaskbarIcon类实现了一个名为TrayBalloonTipClicked的RoutedEventHandler,它被描述为Ballontips点击的处理程序

现在我不知道如何应对这样的点击事件。我只习惯于在XAML定义中定义的事件,如Click=“Button\u Click”,其中我只实现了这样的方法

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);
private void Button_Click(object sender, RoutedEventArgs e)
{
}

有人能帮忙吗?谢谢大家!

谢谢你的帮助,你给了我完美的提示。现在这很好:

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

    } 

您可能正在寻找类似于
tbi.TrayBalloonTipClicked+=tbi\u TrayBalloonTipClicked。正如Dymanoid指出的,有一个stackoverflow链接,您需要事件:我使用