Condividi tramite


GradientStop.Color Property

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

Gets or sets the color of the gradient stop.

Namespace:  System.Windows.Media
Assembly:  System.Windows (in System.Windows.dll)

Syntax

'Declaration
Public Property Color As Color
public Color Color { get; set; }
<GradientStop Color="colorString" .../>

XAML Values

  • 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. For more information, see "XAML Attribute Usage" in Color.

Property Value

Type: System.Windows.Media.Color
The color of the gradient stop. The default is Transparent.

Remarks

Dependency property identifier field: ColorProperty

You can set a color to a static property value of Colors, to additional named colors using string type conversion, or to a Color returned by methods such as FromArgb. For details, see Color.

Examples

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

<StackPanel>
  <!-- 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>
</StackPanel>

Gradient stops in a linear gradient

Gradient with gradient stops.

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.