Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

GradientStop Object

Describes the location and color of a transition point in a gradient.

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

Remarks

Use this class to describe the colors in a LinearGradientBrush or RadialGradientBrush.

GradientStop does not provide an opacity property; to make a GradientStop semi-transparent, set its GradientStop.Color property with a transparent Color.

For more information on GradientStop, see Linear Gradients section in Silverlight Brushes Overview.

Examples

The following example creates a linear gradient with four colors and uses it 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>

The following illustration shows the results of the preceding code, with the highlighted gradient stops.

Gradient stops in a linear gradient

Gradient stops in a linear gradient

See Also

Brush Overview
RadialGradientBrush
LinearGradientBrush

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft. All rights reserved.