tags:

views:

29

answers:

1

Hi,

I have created a custom control that will have a bitmap image in it. My project structure is:

Solution
    ProjectName
        Resources
            Actor.png

The XAML I am using is:

<Image x:Name="ActorBitmap" Source="ProjectName;component/Resources/Actor.png />

However, this is not working. I have the build options on the picture set to "Resource" and "Copy Always". Can someone please explain what I'm doing wrong ?

Thanks,

Scott

+1  A: 

I believe you just need a leading forward slash before the resource location:

<Image x:Name="ActorBitmap" Source="/ProjectName;component/Resources/Actor.png />

There is also no need to set copy to output directory to "Copy Always". Because the build action is set to Resource the image data will be in the assembly itself, and you will not be referencing it from the output directory.

Dan Auclair
Thanks Dan! This worked. My receding hairline is forever grateful...
Scott Davies