2

I want a number of resources to be included in the resulting .exe file, such as a number of images. But I have trouble to access these resources (images) from the RibbonCommands in the XAML file.

I have marked the files and changed their properties to "Embedded Resources", but get problem to refer to them in the Code and the XAML file.

For the Main window I have done the following:

Which works!

But the RibbonCommands does not seem to be able to find Embedded resources.

<r:RibbonCommand x:Key="ScanCommand"  
                 LabelTitle="{x:Static const:strings.Scan}"  
                 ToolTipDescription="{x:Static const:strings.ScanToolTip}"  
                 Executed="ScanDisplayUnit"  
                 LargeImageSource="/EasyLink;component/ScanIcon48x48.png"

The error message I got is:

"/EasyLink;component/ScanIcon48x48.png" is not part of the project

Or it's Build Action property is not set to "Resource"

Is it not possible to use "Embedded Resources" in Ribbons?

Is it correctly understood that the different between "Embedded Resource" and "Resource" is that the "Embedded Resource" include the resources in the resulting .exe file but "Resource" does not do this?

Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
Stefan Olsson
  • 617
  • 3
  • 16
  • 32
  • 1
    see here: [wpf image resources][1] I think there is everything said [1]: http://stackoverflow.com/questions/347614/wpf-image-resources – Random Dev Aug 19 '11 at 09:15
  • No, they are describing how to acccess the images as resources (still outside the .exe) but it does not describe how to access "Embedded images", even this one http://stackoverflow.com/questions/5076927/wpf-accessing-an-embedded-resource-in-xaml refer to "Resources" and not "Embedded Resources" – Stefan Olsson Aug 19 '11 at 10:27
  • Did you have a problem with the Build Action set to "Resource"? My understanding is that this setting enables easier access to resources in XAML...and it still embeds the resource in the assembly. – IanR Aug 19 '11 at 14:02

1 Answers1

2

I just tested this, and as I thought - the difference between "Embedded Resource" and "Resource" isn't that one embeds the resource in the assembly and one doesn't. They both do.

I think the main difference is that "Resource" provides a resource management scheme that is more accessible to WPF applications, so that's the option you should be using for your image.

IanR
  • 4,703
  • 3
  • 29
  • 27