【问题标题】:WPF - Refer to app icon in codeWPF - 参考代码中的应用程序图标
【发布时间】:2009-01-08 02:47:49
【问题描述】:

我已在项目属性中为 WPF 应用添加了一个图标。

如何引用该图标以便将其添加到 我正在为系统托盘创建的 NotifyIcon。

在代码中是??

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

不起作用。 马尔科姆

【问题讨论】:

    标签: wpf


    【解决方案1】:
    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;
    

    【讨论】:

      【解决方案2】:

      我认为这可能是您正在寻找的:

      How do I use an icon that is a resource in WPF?

      您需要将图标作为资源嵌入,然后您可以从代码中访问它。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-08-31
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多