本文介绍了如何在WPF中使用Windows元素(Notifyicon)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是wpf世界的新手.我想使用notifyicon,但我知道wpf不会显示notifyicon,因此我将命名空间用作"System.windows.Forms"
因此,它显示了如下错误
Hi,
I am new to the wpf world. I want to use the notifyicon but I know that wpf is not presenting the notifyicon, so that I am using the namespace as "System.windows.Forms"
Due to this it was showing the error as below
Error 10 ''Application'' is an ambiguous reference between ''System.Windows.Application'' and ''System.Windows.Forms.Application'' E:\All projects\oct\Gmailchecker\Gmailchecker\MainWindow.xaml.cs 248 13 Gmailchecker
我正在尝试这样:
I am trying like this:
NotifyIcon notifyIcon = new NotifyIcon();
this.notifyIcon.BalloonTipText = "hello";
this.notifyIcon.Text = "Gmail Alerts";
this.notifyIcon.Icon = new System.Drawing.Icon("NotifyIcon.ico");
this.notifyIcon.Visible = true;
this.notifyIcon.ShowBalloonTip(1000); /
请尝试帮助我避免此错误.
如何托管此类元素?
谢谢您的关注.
Please try to help me to avoid this error.
How to host this type of element?
Thank you for your attention.
推荐答案
using Forms = System.Windows.Forms
然后使用别名限定NotifyIcon引用:
and then qualify the NotifyIcon references with the alias:
Forms.NotifyIcon notifyIcon = new Forms.NotifyIcon();
这篇关于如何在WPF中使用Windows元素(Notifyicon)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!