Different way how add image to resources
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 fold开发者_开发问答er, 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.
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)
精彩评论