Color (GradientStop)

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

Gets or sets the color of a gradient stop.

<object Color="colorString"  .../>
value = object.Color
object.Color = value

XAML Values

Value

Description

colorString

The Color for a SolidColorBrush expressed as an attribute string. This can be a named color, an RGB value, or an ScRGB value. RGB or ScRGB may also specify alpha information. See the "colorString Grammar" section in Color.

Property Value

Type: Color

The color of the gradient stop.

This property is read/write. The default value is Transparent.

Managed Equivalent

Color

Remarks

You cannot specify a Brush object element such as LinearGradientBrush for this property value by using property element syntax. You can only use XAML attribute syntax to set Color to a color string, as documented in the "colorString Grammar" section of the Color reference topic.

Setting this property in JavaScript also requires the colorString grammar to specify the value as a string, unless you set it to the value of another object's property that is also a Color. See the "Remarks" section in Color for additional information about the scripting usage of the Color object.

Example

The following example creates a LinearGradientBrush with four gradient stops in the implicit GradientStopCollection, which is used to paint a Rectangle.

<Canvas
  xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="https://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

GradientStop