Problem in loading image in WPF
Hi Iam loading im开发者_如何学Goage at runtime.I have the problem where i have to place the image in folder.Actually i put it in folder named as Image.But it shows the error that it can not find image in folder ...bin\debug\HH.bmp.
So i pasted it in debug folder and works fine. But when i take EXE out of Debug folder and when i run it,it does not work. Why? Then how can i add image in such case?
Is there any way to add image in resource file, Like in MFC..
src1 = @"HH.bmp";
Img1.Source = new ImageSourceConverter().ConvertFromString(src1 ) as ImageSource;
If you run this application will search the image in the current Assembly directory. just try like this
<Image source="/yournamespace;component/Images/Close.png">
there should be an image folder with close.png in the solution. No need of the image or image folder in the debug folder.
This is very similar to another question. Check out WPF image resources
EDIT
<Image Source="../Images/icon.png" />
Set the [assembly: NeutralResourcesLanguage("en")] to "en" culture in AssemblyInfo.cs file. Check your assembly resource culture!
[assembly: AssemblyCulture("")]
[assembly: AssemblyConfiguration("")]
[assembly: ComVisible(false)]
[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: NeutralResourcesLanguage("en")]
精彩评论