9

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!

SharpShade
  • 1,761
  • 2
  • 32
  • 45

1 Answers1

24

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

Community
  • 1
  • 1
SvenG
  • 5,155
  • 2
  • 27
  • 36
  • Ah, good to know. Yes i´m using the .resx part. But even if i change the images automatically created in an "Resource" folder in the assembly to "Resource" Compile-action, i get the same result ... – SharpShade Jun 26 '12 at 16:47
  • Added an image which should make it clearer; don't use the resx part of your application. Tip: If you have more than a few images I'd consider making a separate assembly where the images reside and reference them from your other assemblies ... – SvenG Jun 27 '12 at 15:55
  • Thanks for the tip, i will definitely do this. But by the way... it still doesn´t work. I always get this ParseException. That´s my URI: "" And another question: How do i link to the other assembly using a URI? – SharpShade Jul 03 '12 at 15:11
  • Ok i found it out: "pack://application:,,,/MyApp.Resources;component/Icons/Large/document_empty.png" :) But same problem ... – SharpShade Jul 03 '12 at 15:19
  • Sry I don't have a clue why it doesn't work; Have you tried narrowing down the problem, like using another image file, using another control (instead of ribbon button)? Is the document_empty.png valid? – SvenG Jul 03 '12 at 15:35
  • Ah ... a long time later i found the problem. I just found out, that Visual Studio can´t handle chain-references. So the assembly never landed in the bin of the "start"-project. And so the exception came. Now it works, but i have to find a solution to copy the references for the future -.- So thanks for the help :) – SharpShade Jul 03 '12 at 21:27