14.14. Embedding Content in a Silverlight Application

If you want to utilize content such as images within your Silverlight application, you have a number of options, two of which are shown here:

  • Relative path + resource:

    <Image Source="myImage.jpg"></Image>

  • Full URL:

    <Image Source="http://www.mysite.com/myImage.jpg"></Image>

NOTE

Silverlight currently displays only JPG or PNG images. This means that GIF images do not display. The Silverlight team apparently left this out to reduce the size of the plug-in (not to mention GIF becoming a paid standard), but it does seem to be a weird omission. On a related note, if you are interested in manipulating images, you might be interested in checking out www.codeplex.com/imagetools.

The steps to include an image in your project are as follows:

  1. Add the image to the Silverlight project.

  2. Select properties of the image.

  3. Change the Build action to Resource.

    Figure 14.10b. Bundling an image file in a Silverlight project
  4. You can then reference the image as follows:

    <Image Source="myImage.jpg"></Image>

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.148.117.212