5

Hi I found 2 two ways how add image to resources.

First is: For example I create folder images and add some images to this folder, set images build action on Resources. Something like here:

http://www.codewrecks.com/blog/index.php/2010/07/23/bind-an-image-to-a-property-in-wpf/

And second way is use Resources.resx and use AddResources -> AddExistingFile.

Is the result same?

Sorry for my english.

Eric Anastas
  • 21,675
  • 38
  • 142
  • 236

1 Answers1

13

No, it's not the same.

WPF resources should use the "Resource" build action. Resx resources (aka "Embedded resource") are used by Windows Forms, not WPF. They resolve to a System.Drawing.Bitmap, but WPF needs a System.Windows.Media.ImageSource, so you can't use Resx images directly in WPF (you can however convert from a Bitmap to an ImageSource, using the System.Windows.Interop.Imaging class)

Thomas Levesque
  • 286,951
  • 70
  • 623
  • 758