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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

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

• Arial<br />

• Arial Black<br />

• Comic Sans MS<br />

• Courier New<br />

• Georgia<br />

• Lucida Gr<strong>and</strong>e/Lucida Sans Unicode<br />

• Times New Roman<br />

• Trebuchet MS<br />

• Verdana<br />

Additionally, you can download a font using the Downloader control, <strong>and</strong> then use<br />

the SetFontSource method of the TextBlock to assign the font to the text used in the<br />

TextBlock.<br />

You can control how the text is rendered using the FontSize, FontStyle, <strong>and</strong><br />

FontWeight properties. In the case of the latter, the possible values are Thin, ExtraLight,<br />

Light, Normal, Medium, SemiBold, Bold, ExtraBold, Black, <strong>and</strong> ExtraBlack.<br />

You can add decorations to the TextBlock using the TextDecorations property. At present,<br />

it just supports Underline <strong>and</strong> None as values.<br />

You can wrap text using the TextWrapping property. This can contain the values NoWrap<br />

(the text is clipped by the width of the TextBlock) or Wrap, where the text flows onto a new<br />

line when it goes beyond the available width. Note that when text wraps like this, the<br />

width of the text box may be reported inaccurately. Make sure that if you need to read the<br />

width, you check on the actualWidth <strong>and</strong> actualHeight properties for a correct read.<br />

Here’s an example of a TextBlock that uses TextWrapping <strong>and</strong> the Courier New font<br />

family:<br />

<br />

Transformations<br />

XAML allows you to define a transformation that affects how the element will be rendered<br />

on the screen. In computer graphics, items are managed using a mathematical construct<br />

called a matrix. Through use of matrix-based mathematics, coordinates can be easily<br />

manipulated, <strong>and</strong> thus transformations of objects are achievable. <strong>Silverlight</strong> gives you the<br />

facility to define your own matrices, which can be used to define the transformation for

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

Saved successfully!

Ooh no, something went wrong!