In This Article

LinearGradientBrushExtension Class

Implements a markup extension that returns a LinearGradientBrush based on specified parameters.

public class LinearGradientBrushExtension : MarkupExtension
Inheritance:
object MarkupExtension object

Remarks

This class is a markup extension implementation. Markup extension classes exist mainly to provide infrastructure support for some aspect of the WPF XAML processor implementation, but the CreateBrush methods make be utilized from user code to quickly generate brushes.

Constructors

LinearGradientBrushExtension()

Initializes an instance of the class.

public LinearGradientBrushExtension()

LinearGradientBrushExtension(Color, Color)

Initializes an instance of the class using the specified colors.

public LinearGradientBrushExtension(Color startColor, Color endColor)
Parameter Type Description
startColor Color

The start color.

endColor Color

The end color.

Properties

AdditionalStopCount

The additional stops used when creating a LinearGradientBrush.

public int AdditionalStopCount { get; set; }

Property Value

int

Angle

The angle used when creating a LinearGradientBrush. This value is only used when the GradientType is set to CustomAngle.

public double Angle { get; set; }

Property Value

double

EndColor

The end color of the gradient.

[ConstructorArgument("endColor")]
public Color EndColor { get; set; }

Property Value

Color

GradientType

The type of gradient.

public LinearGradientType GradientType { get; set; }

Property Value

LinearGradientType

StartColor

The start color of the gradient.

[ConstructorArgument("startColor")]
public Color StartColor { get; set; }

Property Value

Color

Methods

CreateBrush(Color, Color, LinearGradientType)

Creates a LinearGradientBrush based on the specified parameters.

public static LinearGradientBrush CreateBrush(Color startColor, Color endColor, LinearGradientType gradientType)
Parameter Type Description
startColor Color

The start color of the gradient.

endColor Color

The end color of the gradient.

gradientType LinearGradientType

Type of the gradient that should be created.

Returns

LinearGradientBrush

CreateBrush(Color, Color, LinearGradientType, int)

Creates a LinearGradientBrush based on the specified parameters.

public static LinearGradientBrush CreateBrush(Color startColor, Color endColor, LinearGradientType gradientType, int additionalStopCount)
Parameter Type Description
startColor Color

The start color of the gradient.

endColor Color

The end color of the gradient.

gradientType LinearGradientType

Type of the gradient that should be created.

additionalStopCount int

The number of additional stops that should be included.

Returns

LinearGradientBrush

CreateBrush(Color, Color, double)

Creates a LinearGradientBrush based on the specified parameters.

public static LinearGradientBrush CreateBrush(Color startColor, Color endColor, double angle)
Parameter Type Description
startColor Color

The start color of the gradient.

endColor Color

The end color of the gradient.

angle double

The angle used when creating the brush.

Returns

LinearGradientBrush

CreateBrush(Color, Color, double, int)

Creates a LinearGradientBrush based on the specified parameters.

public static LinearGradientBrush CreateBrush(Color startColor, Color endColor, double angle, int additionalStopCount)
Parameter Type Description
startColor Color

The start color of the gradient.

endColor Color

The end color of the gradient.

angle double

The angle used when creating the brush.

additionalStopCount int

The number of additional stops that should be included.

Returns

LinearGradientBrush

ProvideValue(IServiceProvider)

When implemented in a derived class, returns an object that is provided as the value of the target property for this markup extension.

public override object ProvideValue(IServiceProvider serviceProvider)
Parameter Type Description
serviceProvider IServiceProvider

A service provider helper that can provide services for the markup extension.

Returns

object:

The object value to set on the property where the extension is applied.

Inherited Members

Extension Methods