0

This problem makes me confused. I simply set Background of my Window to an ImageBrush all using Properties window at design time. First, I add a JPG image to my Resources (Double-click on Resources -> Select Images -> Add Existing File ...). Then I select my Window, open Properties window to select ImageSource for the Background property. It shows the image OK at that time. But when running the application, it throws the exception: 'Provide value on 'System.Windows.Baml2006.TypeConverterMarkupExtension' threw an exception.' Line number '75' and line position '10

I don't understand this exception well, searching with Goolge won't help much because there are many various exceptions (inner exception) can throw this. In my case the inner exception is Could not find a part of the path 'D:\Ellipse button with Animation\bin\Debug\Resources\back_ground.jpg'.

The strangest thing is it shows the image OK at design time, but at run time, that exception is thrown.

Do you have any idea to solve this? Thanks!

Hopeless
  • 4,397
  • 5
  • 37
  • 64

2 Answers2

1

hey KingBoy the problem is related to the properties that you have set for your image..right now your image property is set to DesignTime.So make it to Content and Copy Always Everything will just work fine.you can do this by click on your image and then set its properties in property Window..hope it helps you..

loop
  • 9,002
  • 10
  • 40
  • 76
  • sorry but changing it to whatever doesn't seem to work. With my search before, I found some suggestion doing so (change the `Build Action` of my image to `Resource`) but it couldn't help. – Hopeless Jul 26 '13 at 06:47
  • in fact, I've read the suggestion of `ViacheslavSmityukh` before and tried it. it works now. – Hopeless Jul 26 '13 at 06:53
1

Try to set "Copy to out put directory" property of the file to the "Copy always" value

Viacheslav Smityukh
  • 5,652
  • 4
  • 24
  • 42