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.
|
Properties
Methods
Equals, FindName, GetHost, GetValue, SetValue
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="https://schemas.microsoft.com/client/2007" 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> |
The following illustration shows the results of the preceding code, with the highlighted gradient stops.
Gradient stops in a linear gradient