08.01.2015 Views

Beginning Web Development, Silverlight, and ASP.NET AJAX

Beginning Web Development, Silverlight, and ASP.NET AJAX

Beginning Web Development, Silverlight, and ASP.NET AJAX

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 16 ■ PROGRAMMING SILVERLIGHT WITH XAML AND JAVASCRIPT 383<br />

You can see the result of this in Figure 16-3. As the radius is set to 0.1 on both x <strong>and</strong> y,<br />

five circles are used to paint the gradient; <strong>and</strong> as the SpreadMethod is set to Reflect, the<br />

gradient goes from black to white, <strong>and</strong> then white to black, <strong>and</strong> then black to white, <strong>and</strong><br />

so on.<br />

Figure 16-3. Using the RadiusX, RadiusY, <strong>and</strong> SpreadMethod attributes<br />

The ImageBrush<br />

In addition to filling a space with colors or gradients, you can also fill one with pictures<br />

using the ImageBrush. It offers a number of attributes that can be used to set the behavior,<br />

in particular how you control the image’s aspect ratio <strong>and</strong> tiling behavior.<br />

Here’s an example of XAML to define filling a rectangle with an image using the<br />

ImageBrush:<br />

<br />

<br />

<br />

<br />

<br />

You determine how the image is stretched using the Stretch attribute. This can take<br />

several different stretch modes:<br />

None: Renders the image without changing it in any way.<br />

Uniform: Scales the image to fit the dimensions of the fill area without changing the<br />

aspect ratio.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!