Although Silverlight
is a vector-based technology, pixel images are supported
too. The XAML element is (conveniently) named
<Image>.
Apart from the default properties, such as
Canvas.Left,
Canvas.Top,
Height,
and
Width,
<Image> needs to know which
graphics to show. This information is provided in the
Source
property. You can use both local and remote URLs, and you can use two
supported graphics formats: JPEG and PNG.
Example 1 has
the code, and
Figure 1
shows the associated
output.
Example 1. Using an image, the XAML file (Page.xaml, project Image)
<UserControl x:Class="Image.Page"
xmlns="http://schemas.microsoft.com/client/2007"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="400" Height="300">
<Grid x:Name="LayoutRoot" Background="White">
<Canvas>
<Image Source="silverlight.png" />
</Canvas>
</Grid>
</UserControl>