.NET Framework Bookmark and Share   
 index > Windows Presentation Foundation (WPF) > Sharing image/icon files between "ImageSource" in Ribbon Controls
 

Sharing image/icon files between "ImageSource" in Ribbon Controls

I am using ribbon controls (RibbonControlsLibrary.dll) and trying to use one image file between different controls.

I have around ten different projects in a solution. Each of these projects currently have 'Images' folder. Since most of these images are same, i was trying to create a new project with all the images file in the resource and then reference to the all the other projects. It would have worked if I didnt have ribbon control but with ribbon control i get runtime error.

But, interesting part it, I can see my icon/image on xaml designer and when i change the image name on xaml, the designer will update with correct image from the resources, but i get run-time error".
Code sample:

Ref:
xmlns:res="clr-namespace:ResourceLibrary;assembly=ResourceLibrary"

<r:Ribbon Grid.ColumnSpan="2" Grid.Row="0">
<r:Ribbon.Resources
>
<r:RibbonCommand x:Key="cmdOpen"

Executed
="RibbonCommand_Executed"
LabelTitle
="Open"
LabelDescription
="Open project."
LargeImageSource
="/ResourceLibrary;component/Resources/myimg.gif"
SmallImageSource
="/ResourceLibrary;component/Resources/myimg2.gif"/>
.....
.....
</r:Ribbon.Resources
>
</r:Ribbon
>

Then it is called as:

<r:RibbonTab Label="Project">
<r:RibbonGroup
>
<r:RibbonGroup.Command
>
<r:RibbonCommand LabelTitle
="Project" />
</r:RibbonGroup.Command
>
<r:RibbonButton Command="{StaticResource cmdOpen
}"/>
.........
</........>

netlogging
And what runtime error do you get?
Geert van Horrik - CatenaLogic
Visit my blog: http://blog.catenalogic.com

Looking for a way to deploy your updates to all your clients? Try Updater!
Geert van Horrik
Error:
"Cannot convert string '/ResourceLibrary;component/Resources/myimg.gif' in attribute 'LargeImageSource' to object of type 'System.Windows.Media.ImageSource'. Could not load file or assembly 'ResourceLibrary, Culture=neutral' or one of its dependencies. The system cannot find the file specified."
netlogging
There you go, make sure that ResourceLibrary can be loaded (by referencing it, or making sure to copy it to the output directory).
Geert van Horrik - CatenaLogic
Visit my blog: http://blog.catenalogic.com

Looking for a way to deploy your updates to all your clients? Try Updater!
Geert van Horrik
I know thats what the error say.... but 'ResourceLibrary' is referenced. Infact, on xaml designer i even see the icon/image and it compiles without any error. If i change the LargeImageSource to different image, xaml designer even updates and shows the new icon/image and compiles without error. Seems like every thing is working but then whenI run the .exe, I get an error.
netlogging

You can use google to search for other answers

Custom Search

More Threads

• Is it possible to create a scattered plotgraph with data binding from xml in Expression Blend?
• System.InvalidOperationException
• Selector throws an exception when filter filters out all elements
• MediaPlayer hangs, MediaOpened never fires.
• Accessing the application's namespace from a library
• How to make the whole scene visible in a viewport3d?
• Pack URI for user local data?
• Cannot implicitly convert type object to string
• User Control Closed ?
• Canvas.ZIndex