How to display image

Topics: Prism v2 - Silverlight 3
Sep 13, 2009 at 4:53 AM

Hi everybody

I would like to display some images in my SL3 application. As there are a lot of images i created a directory in the ClientBin and put the images inside.

Usually all i have to do is to set the Source of the image control in any usercontrol but with prism my image is not displayed.

May be  because the usercontrol is in a module. When i add the image at the module as resource it displays.

Does anybody encounter this issue?




Sep 14, 2009 at 9:42 PM


You can take the Multitargeting Quickstart which shows different images as an example. Take into account that when you migrate it to Silverlight 3 you will get an error when running the application as the constructor of the resources will be internal. You must make it public in order for it to work.

Please let me know if this helps.

Damian Schenkelman

Sep 16, 2009 at 8:58 AM


In this example the absolute path is set to the source like this.

        <Image Grid.Row="0" Grid.Column="2" HorizontalAlignment="Right" Source="http://localhost:10234/Images/CompanyLogo.jpg" ></Image>
This should works. It is not very nice solution. I'll work around with this solution.


Oct 6, 2009 at 8:57 PM

When I am using CAL (Prism), all the business views are located in Module project where I can not add <ResourceDictionary>. Only the Shell project can add the <ResourceDictionary> but I could not reference the Shell project from my Module but the Shell project reference the module project. So, how could I use the Resources in my Module? Even whe I try to add images in my business module and set the images's Build Action to Resource, the compiler keeps complaining that "Error 5 The file images/AddNew.png is not part of the project or its 'Build Action' property is not set to 'Resource'."

Do you and any examples that the module can define its own image resources and uses them to set the menu bar?




Oct 7, 2009 at 2:05 PM


To use a resource in your module you can define all your resources in a separated library project and refernce this project in your shell.

In your App.xaml you can reference your resources like this. Then you can use your resources in all modules.

                <ResourceDictionary Source="/Skin;component/Color.xaml"/>
                <ResourceDictionary Source="/Skin;component/Button.xaml"/>
                <ResourceDictionary Source="/Skin;component/TextBox.xaml"/>
                <ResourceDictionary Source="/Skin;component/PasswordBox.xaml"/>
                <ResourceDictionary Source="/Skin;component/Combobox.xaml"/>
                <ResourceDictionary Source="/Skin;component/ItemTemplate.xaml"/>

In my case i define some ResourcesDictionary in my library project called Skin.


For your problem about image i didn't encounterer this error. But i add some image in my module with Build Action set to Resource

and it works very well.



Francois Bochaou