Click to Rate and Give Feedback
MSDN
MSDN Library
Web Development
Silverlight
Silverlight 3
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Silverlight 3

Other versions are also available for the following:
.NET Framework Class Library for Silverlight
RadialGradientBrush Class

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

Namespace:  System.Windows.Media
Assembly:  System.Windows (in System.Windows.dll)
Visual Basic (Declaration)
Public NotInheritable Class RadialGradientBrush _
    Inherits GradientBrush
Visual Basic (Usage)
Dim instance As RadialGradientBrush
C#
public sealed class RadialGradientBrush : GradientBrush
XAML Implicit Collection Usage
<object>
  <RadialGradientBrush>
    oneOrMoreGradientStops
  </RadialGradientBrush
</object>

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 code at runtime.

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 a 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 image 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.

Radial gradient with a highlighted focal point

A radial gradient with highlighted components

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

XAML
<StackPanel>
  <!-- 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>
</StackPanel>

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

ms635489.JOLT_local_1928132635_wcpsdk_graphicsmm_4gradientstops_rg(en-us,VS.95).png
System..::.Object
  System.Windows..::.DependencyObject
    System.Windows.Media..::.Brush
      System.Windows.Media..::.GradientBrush
        System.Windows.Media..::.RadialGradientBrush
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2010 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker