Reputation: 2872
I've got this WPF code which works...
Uri iconUri = new Uri("pack://application:,,,/media/images/VS.ico", UriKind.RelativeOrAbsolute);
this.Icon = BitmapFrame.Create(iconUri);
I'm using a windows forms notifyIcon control in my WPF app, and I now need to assing the Icon to it. How do I get from my WPF icon to a System.Drawing.Icon ?
Upvotes: 1
Views: 2443
Reputation: 1773
I use the following method:
// Setup the new NotifyIcon
System.Windows.Forms.NotifyIcon notifyIcon = new System.Windows.Forms.NotifyIcon();
notifyIcon.Text = "Name of Application";
notifyIcon.Icon = new System.Drawing.Icon("media/images/VS.ico");
notifyIcon.Visible = true;
Make sure you add a reference to System.Drawing.
Upvotes: 2
Reputation: 1559
Imaging.CreateBitmapSourceFromHBitmap
I use it like:
return Imaging.CreateBitmapSourceFromHBitmap(source.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
where source is a Bitmap
, which you can get by calling your Icon
's .ToBitmap()
method.
Upvotes: 0