【问题标题】:Using a system icon as application icon in WPF在 WPF 中使用系统图标作为应用程序图标
【发布时间】:2015-10-23 19:50:51
【问题描述】:

正如标题中所说,我想使用来自imageres.dll 的特定图标作为我的 WPF 程序的应用程序图标。

如何做到这一点?

编辑:我已从 DLL 中手动提取图标,但有更简单/更“正确”的方法吗?

【问题讨论】:

    标签: c# wpf dll icons


    【解决方案1】:

    WPF 好像不能直接处理这个。
    但这些链接可能会帮助您找到答案:

    How do I use standard Windows warning/error icons in my WPF app?

    Convert System.Drawing.Icon to System.Media.ImageSource

    不要忘记将图标转换为图像源:

    public static ImageSource ToImageSource(this Icon icon)
    {
        ImageSource imageSource = Imaging.CreateBitmapSourceFromHIcon(
            icon.Handle,
            Int32Rect.Empty,
            BitmapSizeOptions.FromEmptyOptions());
    
        return imageSource;
    }
    

    【讨论】:

      猜你喜欢
      • 2012-02-14
      • 1970-01-01
      • 2013-09-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多