Export (0) Print
Expand All

RadialGradientBrush Object

Paints an area with a radial gradient. A focal point defines the beginning of the gradient, and an ellipse defines the end points of the gradient.

XAML
<RadialGradientBrush ...>
  oneOrMoreGradientStops
</RadialGradientBrush>
Scripting
To create an object using scripting, see CreateFromXAML.

XAML Values

oneOrMoreGradientStops One or more GradientStop object elements. Object elements defined here become members of the collection held by the GradientStops property, when accessed by scripting at runtime.

Remarks

The RadialGradientBrush is similar to the LinearGradientBrush. However, the linear gradient has a start and an end point to define the gradient vector, while the radial gradient has an ellipse, along with a focal point (the GradientOrigin), to define the gradient behavior. The ellipse defines the end point of the gradient. In other words, a gradient stop at 1.0 defines the color at the ellipse circumference. The focal point defines the center of the gradient. A gradient stop at 0 defines the color at the focal point.

The following illustration shows a rectangle filled with a radial gradient. The radial gradient that goes from white to gray. The outside circle represents the gradient ellipse while the red dot denotes the focal point. This gradient has its SpreadMethod set to Pad.

A radial gradient with highlighted components

A radial gradient with highlighted components

Examples

In the following example, a radial gradient brush is used to paint the interior of a rectangle.

XAML
<Canvas
  xmlns="http://schemas.microsoft.com/client/2007"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

  <!-- This rectangle is painted with a radial gradient. -->
  <Rectangle Width="200" Height="100">
    <Rectangle.Fill>
      <RadialGradientBrush GradientOrigin="0.5,0.5" Center="0.5,0.5"
        RadiusX="0.5" RadiusY="0.5">
        <GradientStop Color="Yellow" Offset="0" />
        <GradientStop Color="Red" Offset="0.25" />
        <GradientStop Color="Blue" Offset="0.75" />
        <GradientStop Color="LimeGreen" Offset="1" />
      </RadialGradientBrush>
    </Rectangle.Fill>
  </Rectangle> 
  
</Canvas>

The following illustration shows the gradient created in the previous example. The brush's gradient stops have been highlighted. Notice that, even though the results are different, the gradient stops in this example are identical to the gradient stops in the previous linear gradient brush examples.

Gradient stops in a radial gradient

Gradient stops in a radial gradient

See Also

Brush Overview
LinearGradientBrush

Community Additions

Show:
© 2014 Microsoft