wpf如何实现NotifyIcon

ab413459164 2010-05-08 12:53:19
如题..
...全文
420 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
fy19810925 2010-07-09
  • 打赏
  • 举报
回复
好东西定定定定定定定定定定定定定
Foxer 2010-05-14
  • 打赏
  • 举报
回复
直接用WinForm里的那个NotifyIcon不就行了?
很简单的呀,我已经有程序在用了。

iNotifyIcon = new System.Windows.Forms.NotifyIcon();
this.iNotifyIcon.Visible = false;

Stream st = NcResourceManager.Singleton.GetResource("/SiteDataManager.ico");
if (st != null)
{
try
{
this.iNotifyIcon.Icon = new System.Drawing.Icon(st);

System.Windows.Forms.MenuItem miExit = new System.Windows.Forms.MenuItem("退出", OnNotifyIconExitLick);
System.Windows.Forms.MenuItem miOpenWindow = new System.Windows.Forms.MenuItem("打开窗口", OnNotifyIconOpenWindow);
iNotifyIcon.ContextMenu = new System.Windows.Forms.ContextMenu();
iNotifyIcon.ContextMenu.MenuItems.Add(miExit);
iNotifyIcon.ContextMenu.MenuItems.Add(miOpenWindow);
iNotifyIcon.DoubleClick += new EventHandler(OnNotifyIconOpenWindow);
iNotifyIcon.Text = this.Title + "--停止";

}
catch
{
iNotifyIcon = null;
}
}



protected override void OnStateChanged(EventArgs e)
{
base.OnStateChanged(e);
if (iNotifyIcon != null && this.WindowState == WindowState.Minimized)
{
this.iNotifyIcon.Visible = true;
this.ShowInTaskbar = false;
}

}

public void OnNotifyIconOpenWindow(object sender, EventArgs e)
{
this.iNotifyIcon.Visible = false;
this.ShowInTaskbar = true;
this.WindowState = WindowState.Normal;
this.Activate();
}

private void OnNotifyIconExitLick(object sender, EventArgs e)
{
this.Close();
}
c2u 2010-05-13
  • 打赏
  • 举报
回复
楼上正解,Silverlight/WPF还不提供这个Feature,
目前只能调用Windows API (COM) 接口来实现……
jv9 2010-05-10
  • 打赏
  • 举报
回复
WPF使用notifyicon,下面是详细例程代码,还有详细文字解释。

http://www.codeproject.com/KB/WPF/wpf_notifyicon.aspx

http://www.hardcodet.net/projects/wpf-notifyicon
海涵德 2010-05-09
  • 打赏
  • 举报
回复
使用WCF后就没有必要使用notifyicon了,他返回的结果就是实现了inotifyicon接口的对象。
如return r.tolist

8,734

社区成员

发帖
与我相关
我的任务
社区描述
WPF/Silverlight相关讨论
社区管理员
  • WPF/Silverlight社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧