Export (0) Print
Expand All

GradientStops Property (LinearGradientBrush)

Gets or sets the collection of the brush's gradient stops.

XAML
<LinearGradientBrush ...>
  oneOrMoreGradientStops
</LinearGradientBrush>
Scripting
value = object.GradientStops
object.GradientStops = value

XAML Values

oneOrMoreGradientStops One or more GradientStop object elements.

Property Value

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 GradientStopCollection.

Remarks

The XAML syntax for GradientStops is an example of an implicit collection syntax, where you can omit the GradientStopCollection object element, as well as the <object.GradientStops> property element. Instead, you generally include one or more GradientStop object elements as child elements of a LinearGradientBrush. For more information about XAML implicit collection syntax, see XAML Syntax Overview. (Explicitly including a GradientStopCollection object element is permissible 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.

Examples

The following example creates a LinearGradientBrush with four gradient stops in the implicit GradientStopCollection, which is used to paint 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 diagonal linear gradient. -->
  <Rectangle Width="200" Height="100">
    <Rectangle.Fill>
      <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
        <GradientStop Color="Yellow" Offset="0.0" />
        <GradientStop Color="Red" Offset="0.25" />
        <GradientStop Color="Blue" Offset="0.75" />
        <GradientStop Color="LimeGreen" Offset="1.0" />
      </LinearGradientBrush>
    </Rectangle.Fill>
  </Rectangle>
</Canvas>

Applies To

LinearGradientBrush

See Also

Silverlight Brushes Overview

Community Additions

Show:
© 2015 Microsoft