Table of Contents

Class Shape

Namespace
Avalonia.Controls.Shapes
Assembly
Avalonia.Controls.dll

Provides a base class for shape elements, such as Ellipse, Polygon and Rectangle.

public abstract class Shape : Control, INotifyPropertyChanged, IDataContextProvider, ILogical, IThemeVariantHost, IResourceHost, IResourceNode, IStyleHost, ISetLogicalParent, ISetInheritanceParent, ISupportInitialize, IStyleable, INamed, IInputElement, IDataTemplateHost, ISetterValue
Inheritance
Shape
Implements
Derived
Inherited Members
Extension Methods

Constructors

Shape()

protected Shape()

Fields

FillProperty

Defines the Fill property.

public static readonly StyledProperty<IBrush?> FillProperty

Field Value

StyledProperty<IBrush>

StretchProperty

Defines the Stretch property.

public static readonly StyledProperty<Stretch> StretchProperty

Field Value

StyledProperty<Stretch>

StrokeDashArrayProperty

Defines the StrokeDashArray property.

public static readonly StyledProperty<AvaloniaList<double>?> StrokeDashArrayProperty

Field Value

StyledProperty<AvaloniaList<double>>

StrokeDashOffsetProperty

Defines the StrokeDashOffset property.

public static readonly StyledProperty<double> StrokeDashOffsetProperty

Field Value

StyledProperty<double>

StrokeJoinProperty

Defines the StrokeJoin property.

public static readonly StyledProperty<PenLineJoin> StrokeJoinProperty

Field Value

StyledProperty<PenLineJoin>

StrokeLineCapProperty

Defines the StrokeLineCap property.

public static readonly StyledProperty<PenLineCap> StrokeLineCapProperty

Field Value

StyledProperty<PenLineCap>

StrokeProperty

Defines the Stroke property.

public static readonly StyledProperty<IBrush?> StrokeProperty

Field Value

StyledProperty<IBrush>

StrokeThicknessProperty

Defines the StrokeThickness property.

public static readonly StyledProperty<double> StrokeThicknessProperty

Field Value

StyledProperty<double>

Properties

DefiningGeometry

Gets a value that represents the Geometry of the shape.

public Geometry? DefiningGeometry { get; }

Property Value

Geometry

Fill

Gets or sets the IBrush that specifies how the shape's interior is painted.

public IBrush? Fill { get; set; }

Property Value

IBrush

RenderedGeometry

Gets a value that represents the final rendered Geometry of the shape.

public Geometry? RenderedGeometry { get; }

Property Value

Geometry

Stretch

Gets or sets a Stretch enumeration value that describes how the shape fills its allocated space.

public Stretch Stretch { get; set; }

Property Value

Stretch

Stroke

Gets or sets the IBrush that specifies how the shape's outline is painted.

public IBrush? Stroke { get; set; }

Property Value

IBrush

StrokeDashArray

Gets or sets a collection of double values that indicate the pattern of dashes and gaps that is used to outline shapes.

public AvaloniaList<double>? StrokeDashArray { get; set; }

Property Value

AvaloniaList<double>

StrokeDashOffset

Gets or sets a value that specifies the distance within the dash pattern where a dash begins.

public double StrokeDashOffset { get; set; }

Property Value

double

StrokeJoin

Gets or sets a PenLineJoin enumeration value that specifies the type of join that is used at the vertices of a Shape.

public PenLineJoin StrokeJoin { get; set; }

Property Value

PenLineJoin

StrokeLineCap

Gets or sets a PenLineCap enumeration value that describes the shape at the ends of a line.

public PenLineCap StrokeLineCap { get; set; }

Property Value

PenLineCap

StrokeThickness

Gets or sets the width of the shape outline.

public double StrokeThickness { get; set; }

Property Value

double

Methods

AffectsGeometry<TShape>(params AvaloniaProperty[])

Marks a property as affecting the shape's geometry.

protected static void AffectsGeometry<TShape>(params AvaloniaProperty[] properties) where TShape : Shape

Parameters

properties AvaloniaProperty[]

The properties.

Type Parameters

TShape

Remarks

After a call to this method in a control's static constructor, any change to the property will cause InvalidateGeometry() to be called on the element.

ArrangeOverride(Size)

Positions child elements as part of a layout pass.

protected override Size ArrangeOverride(Size finalSize)

Parameters

finalSize Size

The size available to the control.

Returns

Size

The actual size used.

CreateDefiningGeometry()

Creates the shape's defining geometry.

protected abstract Geometry? CreateDefiningGeometry()

Returns

Geometry

Defining Geometry of the shape.

InvalidateGeometry()

Invalidates the geometry of this shape.

protected void InvalidateGeometry()

MeasureOverride(Size)

Measures the control and its child elements as part of a layout pass.

protected override Size MeasureOverride(Size availableSize)

Parameters

availableSize Size

The size available to the control.

Returns

Size

The desired size for the control.

OnAttachedToVisualTree(VisualTreeAttachmentEventArgs)

Called when the control is added to a rooted visual tree.

protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)

Parameters

e VisualTreeAttachmentEventArgs

The event args.

OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs)

Called when the control is removed from a rooted visual tree.

protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e)

Parameters

e VisualTreeAttachmentEventArgs

The event args.

OnGeometryChanged(object?, EventArgs)

Called when the underlying Geometry changed

protected virtual void OnGeometryChanged(object? sender, EventArgs e)

Parameters

sender object
e EventArgs

OnPropertyChanged(AvaloniaPropertyChangedEventArgs)

Called when a avalonia property changes on the object.

protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)

Parameters

change AvaloniaPropertyChangedEventArgs

The property change details.

Render(DrawingContext)

Renders the visual to a DrawingContext.

public override sealed void Render(DrawingContext context)

Parameters

context DrawingContext

The drawing context.