A radial gradient brush paints an area with a radial
gradient that has a circle, along with a focal point, to define the gradient
behavior. The focal point defines the center of the gradient and has default
value 0.0. The RadialGradientBrush object represents a radial gradient brush.
Figure 21 shows a radial gradient.
Figure 21. Radial Gradient
Figure 22. Radial Gradient with Stops
Creating a Radial Gradient Brush
The RadialGradientBrush element in XAML creates a radial
gradient brush.
The Center property of the RadialGradientBrush represents
the center of the outermost circle of the radial gradient. The default center
point of the gradient circle is (0.5, 0.5).
The GradientOrigin property of the RadialGradientBrush
represents the location of the focal point of the gradient.The default focal point of the gradient
circle is (0.5, 0.5).
The RadiusX and the RadiusY properties of the
RadialGradientBrush represent the X and Y radius of the radial gradient.
The following code snippet creates a radial gradient brush
with blue and red colors by setting GradientStops. The GradientOrigin and
Center properties are default properties. The code snippet also sets the
RadiusX and RadiusY properties.
<RadialGradientBrush
GradientOrigin="0.5,0.5"
Center="0.5,0.5"
RadiusX="0.5" RadiusY="0.5">
<RadialGradientBrush.GradientStops>
<GradientStop Color="Blue"
Offset="0" />
<GradientStop Color="Red"
Offset="1.0" />
</RadialGradientBrush.GradientStops>
</RadialGradientBrush>
We can fill a shape with a radial gradient brush by setting
a shape's Fill property to the gradient brush. The code snippet in Listing 18 creates
a rectangle shape sets the Fill property to a RadialGradientBrush with blue and
red colors where center of the radial gradient starts with the blue color.
sujith rPosted Jan 7, 2013, 8:40 AM
great job