Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XamlParseException on setting image from resources

i got some trouble. I just implemented the Microsoft Ribbon Framework into my application. Now i wanted to set an icon for one button. So i wrote:

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

But everytime i start the app, i got an "XamlParseException" in this line, with the inner exception: "File not found".

Why the hell is this so? I don´t understand, why it doesn´t find the image. It´s just placed in the resources of the assembly. The designer show´s it and the code doesn´t get highlighted as it was an syntax error or something like that...

Anyone who has this problem too?

Thanks!

like image 549
SharpShade Avatar asked Jun 26 '12 13:06

SharpShade


1 Answers

As you haven't specified exactly, I assume 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 on SO

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

See picture: enter image description here

In your Markup use the packUri:

pack://application:,,,/images/IMG.jpg

like image 163
SvenG Avatar answered Nov 11 '22 12:11

SvenG