Reputation: 29
I am trying to display an image in my code. I have given the location of the image i added in imagesource. This gives me the above error. But when i change the image file name to an already exiting image file in the image folder say file1.png, it works fine. what is it that i am doing wrong? i tried to add different files in this folder, all have issues except the exiting ones
Upvotes: 2
Views: 1718
Reputation: 155
Had the same problem, but it looks like its a "convoluted error" thrown by WPF for "image not found"! I corrected my image path (in my case, its a relative resource, so just added the missing dot) and the error disappeared! I couldn't believe it at first, but I was convinced when I was able to repro this bug just by replacing the UriSource
with bad path, again and again!
<Image Width="200" Height="32">
<Image.Source>
<BitmapImage DecodePixelWidth="200" DecodePixelHeight="32" UriSource=".\Resources\Image\logo.png" />
</Image.Source>
</Image>
Check your image path, or make sure the image file name matches the one specified in the UriSource
; it should work.
Upvotes: 3
Reputation: 11
You are not being very specific in your question so hard to answer. Could be an error in the image. Try opening the picture in photoshop or the like to see if any errors appear. Or try checking the properties of the image. Build action should be Resource but is sometimes set to Content when added to the project.
Hope this help you. This have given me lots of headaces before anyways :)
Upvotes: 0