Reputation: 6577
How to add images in Silver light?
Upvotes: 3
Views: 8494
Reputation: 2032
The first thing you should do is add the image to your silverlight project. I usually make a folder in my project called images.
Once you have the images in your project then you will ensure that on publish these images will also get published.
The second thing I have learned the hard way is that silverlight does not support all kinds of images. Mainly you can't use jpegs. I suggest you use png file format.
To convert your images to png I use a free imaging application called Paint.net
Once you have a png image in your project then add the image using XAML like this:
<Canvas>
<Image Source="Images/OnlineChess.png" Stretch="Fill" Canvas.Left="350" Canvas.Top="74"
Width="100" Height="103" Margin="10,10,10,10"/>
</Canvas>
Upvotes: 4
Reputation: 3656
If you simply want to add a local image to an xaml control use the following:
<Image x:Name="LocalImage" Source="Path/MyImage.png" Margin="10,10,0,0" Width="16" Height="16" HorizontalAlignment="Left" VerticalAlignment="Top" />
If this is not what you want, then you may need to be more detailed with your question.
Upvotes: 7