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.

384<br />

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

UniformToFill: Scales the image completely to fill the desired area, preserving its<br />

aspect ratio <strong>and</strong> clipping it if necessary.<br />

Fill: Scales the image to fill the desired area using independent scaling on the x- <strong>and</strong><br />

y-axes. This will distort the image to completely fill the available space.<br />

To complement stretching the image, you can also set the image alignment using the<br />

AlignmentX <strong>and</strong> AlignmentY attributes. When the image doesn’t fill the paint area, it can<br />

then be aligned as you desire by setting these properties. As you would expect, the values<br />

for AlignmentX are Left, Right, <strong>and</strong> Center, <strong>and</strong> the values for AlignmentY are Top, Bottom,<br />

<strong>and</strong> Center.<br />

Here’s an example of XAML that fills four rectangles with the same image, but sets<br />

each of them to a value from the different stretch modes, setting their alignments to the<br />

bottom right-h<strong>and</strong> corner.<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

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

Saved successfully!

Ooh no, something went wrong!