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 387<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

When using strokes, you have a number of other properties that you can use to finetune<br />

their appearance.<br />

The width of your stroke is set using the width property. When painting a stroke with<br />

something like a gradient brush, it is hard to see the gradient if your stroke is only 1 pixel<br />

wide, so it’s very straightforward to change the width <strong>and</strong> have the brush show up a lot<br />

better.<br />

The way the stroke is drawn is configured using the StrokeDashArray, StrokeDashCap,<br />

<strong>and</strong> StrokeDashOffset properties. The StrokeDashArray specifies how you would like the<br />

line broken into dashes by configuring it using an array of double values. This is a commaseparated<br />

list of values in which you set a value for the stroke length, followed by a value<br />

for the space length, <strong>and</strong> then repeat as necessary. For example, if you want your dash to<br />

be 3 units long, followed by a space 1 unit long, followed by a dash 2 units long, followed<br />

by a space 1 unit long, you would use a dash array that contains “3,1,2,1.”<br />

If you use this method <strong>and</strong> you have a large width on your lines, you’ll see that your<br />

lines are in fact rectangles with sharp corners. You can change this using the StrokeDashCap<br />

property, which allows you to set your dashes to have the following end caps:<br />

Flat: The default value, where the line ends flat, giving squared-off corners<br />

Round: Specifies that the end cap is a semicircle with the same diameter as the line<br />

thickness<br />

Triangle: Specifies an isosceles triangle end cap, where the base length equals the<br />

thickness of the stroke<br />

If you are drawing a shape that has sharp turns on it, such as the corners of a rectangle,<br />

you may notice that the dashes do not join up cleanly in many cases due to their dash<br />

array not lining up with the specified widths of the shape. To control this a little better,<br />

you can specify how strokes will join up with each other when they go through a turn.<br />

This is set using the StrokeLineJoin property. You can set this to have the following join<br />

types:

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

Saved successfully!

Ooh no, something went wrong!