LinearGradientBrush class

Applies to Windows and Windows Phone

Paints an area with a linear gradient.

Inheritance

Object
  DependencyObject
    Brush
      GradientBrush
        LinearGradientBrush

Syntax


public sealed class LinearGradientBrush : GradientBrush


<LinearGradientBrush ...>
  oneOrMoreGradientStops
</LinearGradientBrush

XAML Values

oneOrMoreGradientStops

One or more GradientStop object elements. Object elements defined here become members of the collection when code accesses the GradientStops property at run time.

Attributes

[MarshalingBehavior(Agile)]
[Threading(Both)]
[Version(0x06020000)]
[WebHostHidden()]

Members

The LinearGradientBrush class has these types of members:

Constructors

The LinearGradientBrush class has these constructors.

ConstructorDescription
LinearGradientBrush() Initializes a new instance of the LinearGradientBrush class.
LinearGradientBrush(GradientStopCollection, Double) Initializes a new instance of the LinearGradientBrush class that has the specified GradientStopCollection and angle.

 

Methods

The LinearGradientBrush class has these methods. It also inherits methods from the Object class.

MethodDescription
ClearValue Clears the local value of a dependency property. (Inherited from DependencyObject)
GetAnimationBaseValue Returns any base value established for a dependency property, which would apply in cases where an animation is not active. (Inherited from DependencyObject)
GetValue Returns the current effective value of a dependency property from a DependencyObject. (Inherited from DependencyObject)
ReadLocalValue Returns the local value of a dependency property, if a local value is set. (Inherited from DependencyObject)
SetValue Sets the local value of a dependency property on a DependencyObject. (Inherited from DependencyObject)

 

Properties

The LinearGradientBrush class has these properties.

PropertyAccess typeDescription

ColorInterpolationMode

Read/writeGets or sets a ColorInterpolationMode enumeration value that specifies how the gradient's colors are interpolated. (Inherited from GradientBrush)

Dispatcher

Read-onlyGets the CoreDispatcher that this object is associated with. (Inherited from DependencyObject)

EndPoint

Read/writeGets or sets the ending two-dimensional coordinates of the linear gradient.

EndPointProperty

Read-onlyIdentifies the EndPoint dependency property.

GradientStops

Read/writeGets or sets the brush's gradient stops. (Inherited from GradientBrush)

MappingMode

Read/writeGets or sets a BrushMappingMode enumeration value that specifies whether the positioning coordinates of the gradient brush are absolute or relative to the output area. (Inherited from GradientBrush)

Opacity

Read/writeGets or sets the degree of opacity of a Brush. (Inherited from Brush)

RelativeTransform

Read/writeGets or sets the transformation that is applied to the brush using relative coordinates. (Inherited from Brush)

SpreadMethod

Read/writeGets or sets the type of spread method that specifies how to draw a gradient that starts or ends inside the bounds of the object to be painted. (Inherited from GradientBrush)

StartPoint

Read/writeGets or sets the starting two-dimensional coordinates of the linear gradient.

StartPointProperty

Read-onlyIdentifies the StartPoint dependency property.

Transform

Read/writeGets or sets the transformation that is applied to the brush. (Inherited from Brush)

 

Examples

This example creates a linear gradient with four colors and uses it to paint a Rectangle.


<StackPanel>
  <!-- This rectangle is painted with a vertical linear gradient. -->
  <Rectangle Width="200" Height="100">
    <Rectangle.Fill>
      <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,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>


This illustration shows the resulting gradient. The gradient axis is marked with a dashed line and the gradient stops are marked with circles.

Gradient axis for a vertical gradient

Requirements

Minimum supported client

Windows 8 [Windows Store apps only]

Minimum supported server

Windows Server 2012 [Windows Store apps only]

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

Windows.UI.Xaml.Media
Windows::UI::Xaml::Media [C++]

Metadata

Windows.winmd

See also

GradientBrush

 

 

Show:
© 2014 Microsoft