将System.Windows.Media.ImageSource转换为Windows.Drawing.Icon?

时间:2018-07-10 15:28:16

标签: c# .net wpf icons system.drawing

有没有简单的方法可以将ImageSource转换为Icon?我的用例:我将Window.Icon属性(类型为System.Windows.Media.ImageSource)用作NotifyIcon.Icon(即System.Drawing.Icon)的相同图标,如下所示:

 // ...

        this.notifyIcon = new System.Windows.Forms.NotifyIcon()
        {
            Icon = ConvertToIcon(this.Icon),
        };

 // ...

 public System.Drawing.Icon ConvertToIcon(ImageSource imageSource)
 {
      // Implementation?
 }

任何内置或简单的方法可以做到这一点?

0 个答案:

没有答案
相关问题