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.

388<br />

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

Bevel: This shaves the edges off the join, thus smoothing it.<br />

Miter: This keeps the default edging.<br />

Round: This rounds off the edges of the join.<br />

Using Visual Elements in XAML<br />

Earlier, you saw several of the common visual elements that are used in XAML, including<br />

Canvas.Top <strong>and</strong> Canvas.Left. There are a number of other properties that many XAML elements<br />

have in common. In this section, you’ll take a look at these, <strong>and</strong> from there you’ll<br />

be able to underst<strong>and</strong> the subsequent sections a little better!<br />

Dimension <strong>and</strong> Position Properties<br />

You’ll typically use the Height <strong>and</strong> Width properties to set the dimensions of an item.<br />

These take a double value—so, for example, to create a 50✕100 rectangle, you define its<br />

XAML as follows:<br />

<br />

The properties for setting the location of an item are Canvas.Top <strong>and</strong> Canvas.Left.<br />

These have a special syntax, called attached properties, as they are ultimately related to<br />

the parent element. So, to set the same rectangle to appear 50 pixels from the left <strong>and</strong> 50<br />

pixels down from the top of its container, you would use this XAML:<br />

<br />

Opacity<br />

Most shapes allow their alpha channels to be set. This can be done with the alpha channel<br />

on a shape’s fill brush (with the exception of the VideoBrush). In addition, most<br />

elements allow you to use the Opacity property, which is a normalized double with 0 representing<br />

invisible, 1 representing visible, <strong>and</strong> everything in between representing a<br />

degree of opacity relative to the specified value.<br />

Cursor Behavior<br />

To provide good feedback to your users, it is often necessary to change the mouse cursor<br />

to indicate the type of action that is appropriate. XAML elements expose a Cursor property<br />

that allows you to set the following values:

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

Saved successfully!

Ooh no, something went wrong!