Embedded images not showing when in a UserControl
image, silverlight, wpf, xaml
Solution
You have to reference it as a resource, not just the path. This is how it is done in a WPF application:
<Image Source="/MyAppName;component/images/image.png" Stretch="None" />
The original image is located in images/image.png
Note: I have no experience in SilverLight, but you said it is probably similiar in WPF, so I suggest this...
Problem
I have an Image control that contains a path to an embedded image (build action 'resource'). ``` <Image Source="Assets/images/image.png" Stretch="None" /> ``` If I add that to a container in my MainPage.xaml the image appears fine. When having the same image in a UserControl as shown below, and then adding an instance of that UserControl on MainPage.xaml the image does not appear. ``` <UserControl x:Class="HomePage.Views.SimpleUserContol" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" > <Grid x:Name="LayoutRoot" > <Image Source="Assets/images/image.png" Stretch="None" /> </Grid> </UserControl> ``` Can anyone shed any light on why this happening and maybe point me in the direction of a solution. Cheers, J (I'm working in Silverlight but would think the same thing probably happens in WPF) EDIT: Setting ``` <Image Source="/Assets/images/image.png" Stretch="None" /> ``` works fine when setting the build action to 'Content' however it doesn't work when using 'resource'. The problem is definatly it's relative position in the file structure as add ../ works fine. I'd still like a solution to get an image from the assembly if possible