Reputation: 12864
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
Upvotes: 1
Views: 6485
Reputation: 5488
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;
Upvotes: 9
Reputation: 1552
I think this may be what you are looking for:
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.
Upvotes: 2