Store Images as Resources into ResourceDictionary in WPF
The point of this is all the elements, which have this image on it, will be at the same time updated once this image source is changed to refer to another image. It is a centralized way to manage all the images. Do it as followling:
Add “ImageSource” entry in a ResourceDictionary.
<ImageSource x:Key=”someImage”>Images/SomeImage.extension</ImageSource>
P.S.
Strongly recommended to put all the images in one folder called “Images” under the main project folder.
You saved my night,My wife wish to you best wishes. 😉
a man said this on May 5, 2008 at 10:54 am |
Super nice idea. Thx Alex
Alex said this on November 13, 2008 at 12:48 pm |
Ahh.. ImageSource! Thanks!
JP Chow said this on December 1, 2008 at 4:19 pm |
I have been experimenting with putting the resouces in an external library, images included but when I reference the external resource
The images that are in the Skin.dll as resources are not visible to the WPF application that is referencing the Skin.dll Do you know why the WPF app is unable to get to the images in the Skin.dll?
Aaron said this on June 9, 2009 at 3:52 pm |
Probably specifying full Uri for ImageSource can solve that, for example:
/Skin;component/Images/SomeImage.extension
Denni said this on July 4, 2012 at 5:16 am |
Good work Martin!
This opens teh door to a lot of possibilities.
You helped me realise that ANY object can be placed in a ResourceDictionary
baraholka1 said this on February 23, 2010 at 6:47 pm |