Freigeben über


GradientStops (RadialGradientBrush)

Microsoft Silverlight will reach end of support after October 2021. Learn more.

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

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

XAML Values

Value

Description

oneOrMoreGradientStops

One or more GradientStop object elements.

Property Value

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.

Managed Equivalent

GradientStops

Remarks

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.

Example

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.

<Canvas  
  xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml"> 

  <Image Source="sampleImages/forest.jpg" Height="100">
    <Image.OpacityMask>
      <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" />
      </RadialGradientBrush>
    </Image.OpacityMask>
  </Image> 
</Canvas>

Applies To

RadialGradientBrush

See Also

Reference