This is an old revision of the document!


Resources

Embedding an Application Icon

  • Create App.rc:
    101 ICON "images\\Application.ico"
    102 ICON "images\\Document.ico"
    103 ICON "images\\Help.ico"
  • Compile using Resource Compiler (Visual Studio Command Line):
    C:\> rc App.rc 
  • Add App.res to the project (leave None as the Build Action).
  • Select icon for project: Project > Properties > Application > Resources: Icon and Manifest.
  • Build.

Source: StackOverflow: Dmitry Schechtman, "Embed multiple icons in WPF EXE"

Referencing Resources from an Assembly

In XAML, to reference an image in images/icons/icon-product-acme1.png in assembly Acme.Products.Specifications.dll, you need to use the pack notation (for package).

Local Assembly (no pack notation required):

<Image Source="/images/icons/icon-product-acme1.png" Width="35" Height="35" Margin="5" />

Referenced Assembly:

<Image Source="pack://application:,,,/Acme.Products.Specifications;component/images/icons/icon-product-acme1.png" Width="35" Height="35" Margin="5" />

NOTE: Make sure the image file is compiled as Resource (not Embedded Resource or Content) in the assembly.

References