Silverlight : how to put a simple image?

58 Views Asked by At

I have troubles with element. Well, I think my path should be wrong but I dont find the problem.

Here is my simple code :

<UserControl x:Class="videoplayer.Page"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
Width="400" Height="300">
<Grid x:Name="LayoutRoot" Background="Black">
        <Image x:Name="btnPlay" Source="cat.jpg" />
</Grid>
</UserControl>*

I have put the file cat.jpg in the same directory that the .xap file, in the parent directory too, and again in the parent directory, but i still dont see any cat when I launch the application ! :(

Only the black grid ...

Someone see the mistake ? Thanks !

ps : it's silverlight 2 sdk

2

There are 2 best solutions below

0
On

You have to include the file in your project as a source. then in the property inspector select the image for the Source attribute.

0
On

The image will need to have a build-action setting of Resource.

From within Visual Studio:

  • Select the file,
  • open the Properties view,
  • select Resource from the Build Action drop-down.