XamlParseException when setting up image from resources

I had some problems. I just implemented Microsoft Ribbon Framework in my application. Now I wanted to set the icon for one button. So I wrote:

<Ribbon:RibbonButton Header="Create Project" LargeImageSource="pack://application:,,,/Resources/document_empty.png" /> 

But every time I run the application, I have a "XamlParseException" on this line with an internal exception: "File not found."

Why the hell is that so? I do not understand why he does not find the image. It is simply placed in build resources. The designer shows this, and the code does not stand out because it was a syntax error or something like that ...

Anyone who has this problem?

Thanks!

+7
source share
1 answer

As you did not specify, I assume that you are using the Properties \ resources.resx part of your application? If so, this is not the desired way for a WPF application.

See this post in SO format

Instead, create a folder in your assembly, place your images there and set its assembly action to the resource.

See image: enter image description here

In your markup, use packUri:

package: // Application: ,, / image / IMG.jpg

+19
source

All Articles