GradientStops (RadialGradientBrush)


Gets or sets the collection of gradient stops for a RadialGradientBrush object.

<RadialGradientBrush ...>
value = object.GradientStops
object.GradientStops = value




One or more GradientStop object elements.

Type: GradientStopCollection

A collection of the GradientStop objects associated with the brush, each of which specifies a color and an offset along the brush's gradient axis.

This property is read/write. The default value is an empty collection.

The XAML syntax for GradientStops is an example of an implicit collection syntax, where you can omit the GradientStopCollection object element and the <RadialGradientBrush.GradientStops> property element. Instead, you generally include one or more GradientStop object elements as child elements of a RadialGradientBrush. Explicitly including a GradientStopCollection object element is permissible in XAML syntax, and might be useful if you intend to name the collection in XAML and manipulate its contents through script later.

Generally, a GradientStopCollection contains a minimum of two gradient stops.

The following example creates a RadialGradientBrush with three gradient stops in the implicit GradientStopCollection. The three gradient stops specify a brush with varying transparency, which is then applied as the OpacityMask for an Image.


  <Image Source="sampleImages/forest.jpg" Height="100">
      <RadialGradientBrush Center="0.5,0.5">
        <!-- This gradient stop is partially transparent. -->
        <GradientStop Color="#00000000" Offset="1" />
        <!-- This gradient stop is partially transparent. -->
        <GradientStop Color="#20000000" Offset="0.8" />
        <!-- This gradient stop is fully opaque. -->
        <GradientStop Color="#FF000000" Offset="0" />

Community Additions