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 a new instance of the LinearGradientBrushExtension class.

public LinearGradientBrushExtension()

LinearGradientBrushExtension(Color, Color)

Initializes a new instance of the LinearGradientBrushExtension 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

Gets or sets the additional stops used when creating a LinearGradientBrush.

public int AdditionalStopCount { get; set; }

Property Value

int:

The additional stops.

Angle

Gets or sets 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:

The angle.

EndColor

Gets or sets the end color of the gradient.

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

Property Value

Color:

The end color.

GradientType

Gets or sets the type of gradient.

public LinearGradientType GradientType { get; set; }

Property Value

LinearGradientType:

The type of gradient.

StartColor

Gets or sets the start color of the gradient.

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

Property Value

Color:

The start 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:

A new 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:

A new 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:

A new 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:

A new LinearGradientBrush.

ProvideValue(IServiceProvider)

Creates and returns a LinearGradientBrush based on the current state of this object. extension.

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

Object that can provide services for the markup extension.

Returns

object:

A new LinearGradientBrush.

Inherited Members