tags:

views:

639

answers:

2

Hi,

i have added an icon to a WPF app in the project properties.

How do I refer to that icon so I can add it to a NotifyIcon that I am creating for system tray.

In code that is??

  System.Windows.Forms.NotifyIcon ni = new System.Windows.Forms.NotifyIcon();
  ni.Icon = new System.Drawing.Icon("MyIcon.ico");

Does not work. Malcolm

+1  A: 

I think this may be what you are looking for:

http://stackoverflow.com/questions/74466/how-do-i-use-an-icon-that-is-a-resource-in-wpf

You need to embed the icon as a resource and then you can access it from code.

Ben McIntosh
A: 
System.Windows.Forms.NotifyIcon ni = new System.Windows.Forms.NotifyIcon();
ni.Icon = System.Drawing.Icon.ExtractAssociatedIcon(
             System.Reflection.Assembly.GetEntryAssembly().ManifestModule.Name);
ni.Visible = true;
Stanislav Kniazev