Table of Contents

Class Canvas

Namespace
Avalonia.Controls
Assembly
Avalonia.Controls.dll

A panel that displays child controls at arbitrary locations.

public class Canvas : Panel, INotifyPropertyChanged, IDataContextProvider, ILogical, IThemeVariantHost, IResourceHost, IResourceNode, IStyleHost, ISetLogicalParent, ISetInheritanceParent, ISupportInitialize, IStyleable, INamed, IInputElement, IDataTemplateHost, ISetterValue, IChildIndexProvider, INavigableContainer
Inheritance
Canvas
Implements
Derived
Inherited Members
Extension Methods

Remarks

Unlike other Panel implementations, the Canvas doesn't lay out its children in any particular layout. Instead, the positioning of each child control is defined by the

Canvas.Left
,
Canvas.Top
,
Canvas.Right
and
Canvas.Bottom
attached properties.

Constructors

Canvas()

public Canvas()

Fields

BottomProperty

Defines the Bottom attached property.

public static readonly AttachedProperty<double> BottomProperty

Field Value

AttachedProperty<double>

LeftProperty

Defines the Left attached property.

public static readonly AttachedProperty<double> LeftProperty

Field Value

AttachedProperty<double>

RightProperty

Defines the Right attached property.

public static readonly AttachedProperty<double> RightProperty

Field Value

AttachedProperty<double>

TopProperty

Defines the Top attached property.

public static readonly AttachedProperty<double> TopProperty

Field Value

AttachedProperty<double>

Methods

ArrangeChild(Control, Size)

Arranges a single child.

protected virtual void ArrangeChild(Control child, Size finalSize)

Parameters

child Control

The child to arrange.

finalSize Size

The size allocated to the canvas.

ArrangeOverride(Size)

Arranges the control's children.

protected override Size ArrangeOverride(Size finalSize)

Parameters

finalSize Size

The size allocated to the control.

Returns

Size

The space taken.

GetBottom(AvaloniaObject)

Gets the value of the Bottom attached property for a control.

public static double GetBottom(AvaloniaObject element)

Parameters

element AvaloniaObject

The control.

Returns

double

The control's bottom coordinate.

GetLeft(AvaloniaObject)

Gets the value of the Left attached property for a control.

public static double GetLeft(AvaloniaObject element)

Parameters

element AvaloniaObject

The control.

Returns

double

The control's left coordinate.

GetRight(AvaloniaObject)

Gets the value of the Right attached property for a control.

public static double GetRight(AvaloniaObject element)

Parameters

element AvaloniaObject

The control.

Returns

double

The control's right coordinate.

GetTop(AvaloniaObject)

Gets the value of the Top attached property for a control.

public static double GetTop(AvaloniaObject element)

Parameters

element AvaloniaObject

The control.

Returns

double

The control's top coordinate.

MeasureOverride(Size)

Measures the control.

protected override Size MeasureOverride(Size availableSize)

Parameters

availableSize Size

The available size.

Returns

Size

The desired size of the control.

SetBottom(AvaloniaObject, double)

Sets the value of the Bottom attached property for a control.

public static void SetBottom(AvaloniaObject element, double value)

Parameters

element AvaloniaObject

The control.

value double

The bottom value.

SetLeft(AvaloniaObject, double)

Sets the value of the Left attached property for a control.

public static void SetLeft(AvaloniaObject element, double value)

Parameters

element AvaloniaObject

The control.

value double

The left value.

SetRight(AvaloniaObject, double)

Sets the value of the Right attached property for a control.

public static void SetRight(AvaloniaObject element, double value)

Parameters

element AvaloniaObject

The control.

value double

The right value.

SetTop(AvaloniaObject, double)

Sets the value of the Top attached property for a control.

public static void SetTop(AvaloniaObject element, double value)

Parameters

element AvaloniaObject

The control.

value double

The top value.