Often used WPF Syntax (and it's hard to remember – at least for me :( )

Path to an image located in our project:

<Image Source="/My.Asembly.Name;component/Path/to/my/image.png" ... />

Image path  is in the formation of <AssembleName>;component/<Path2YourImageWithinTheAssembly>.

Useful tips:

  • To get the formation of the image path, just open design mode, add an image and select its source as an image in your project/solution and see the result.
  • We can omit the AssemblyName part if the code and the image are in them same assembly.
    i.e. Only keep <Path2YourImageWithinTheAssembly> in the image path.

<Image Source="Path/to/my/image/without/assembly.png" ... />



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: