XAML Brushes and Silverlight
(Page 1 of 4 )
In this conclusion to a three-part series on using Sliverlight and XAML, you will learn about the versatility of XAML brushes. It is excerpted from chapter four of
Essential Silverlight, written by Christian Wenz (O'Reilly, 2008; ISBN: 0596519982). Copyright © 2007 O'Reilly Media, Inc. All rights reserved. Used with permission from the publisher. Available from booksellers or direct from O'Reilly Media.
Using Images
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

Figure 4-11. The pixel image within the Silverlight content
both local and remote URLs, and you can use two supported graphics formats: JPEG and PNG. Example 4-12has the code, and Figure 4-11 shows the associated output.
Example 4-12. Using an image, the XAML file (Image.xaml)
<Canvas xmlns=http://schemas.microsoft.com/client/2007"
xmlns:x="http:// schemas.microsoft.com/winfx/2006/xaml">
<Image Source="silverlight.png" />
</Canvas>
When using images, you can also track the data transfer using JavaScript, as Chapter 9 shows.
Next: Using Brushes >>
More BrainDump Articles
More By O'Reilly Media
|
This article is excerpted from chapter four of Essential Silverlight, written by Christian Wenz (O'Reilly, 2008; ISBN: 0596519982). Check it out today at your favorite bookstore. Buy this book now.
|
|