LinearGradientBrush


LinearGradientBrushHierarchy: DependencyObject Freezable Animatable Brush GradientBrush

 <LinearGradientBrush     StartPoint="0,0"     EndPoint="5,5"     <LinearGradientBrush.GradientStops>         <GradientStop Color="Yellow" Offset="0" />         <GradientStop Color="Green" Offset="0.5" />     </LinearGradientBrush.GradientStops> </LinearGradientBrush> 

or:

 <LinearGradientBrush>     <LinearGradientBrush.StartPoint>         <Point X="0" Y="0" />     </LinearGradientBrush.StartPoint>     <LinearGradientBrush.EndPoint>         <Point X="5" Y="5" />     </LinearGradientBrush.EndPoint>     <LinearGradientBrush.GradientStops>         <GradientStop Color="Yellow" Offset="0" />         <GradientStop Color="Green" Offset="0.5" />     </LinearGradientBrush.GradientStops> </LinearGradientBrush> 

<LinearGradientBrush .../> paints an area with a linear gradient. Colors in the gradient are interpolated along a diagonal path. LinearGradientBrush can be specified as an attribute on XAML elements using abbreviated markup syntax (Example 7-3). Figure 7-6 shows an example of using a LinearGradientBrush to paint a Rectangle element.

Figure 7-6. Painting a Rectangle with a LinearGradientBrush


Attributes


EndPoint (optional)

The ending Point of the linear gradient. Specified either as a Point through abbreviated markup or explicitly declared as a Point. The default is the lower-right corner (1,1).


GradientStops (optional)

A collection of GradientStop elements specifying the location and color of each change in the gradient.

To simplify the creation of linear gradients, two gradient types can be quickly created through abbreviated markup syntax: HorizontalGradient and VerticalGradient:

 <element attribute="HorizontalGradient StartColor EndColor" /> <element attribute="VerticalGradient UpperColor LowerColor" /> 

These gradients are assumed to encompass the entire layout region of the element to which they are attached. HorizontalGradient paints the region with a gradient from left (StartColor) to right (EndColor), while VerticalGradient paints the region with a gradient from top (UpperColor) to bottom (LowerColor). An example of each is shown in Figure 7-7.


StartPoint (optional)

The starting Point of the linear gradient. Specified either as a Point through abbreviated markup or explicitly declared as a Point. The default is the upper-left corner (0,0).

Figure 7-7. Example of Horizontal and Vertical linear gradient brushes





XAML in a Nutshell
XAML in a Nutshell (In a Nutshell (OReilly))
ISBN: 0596526733
EAN: 2147483647
Year: 2007
Pages: 217

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net