Table of Contents

Class Viewbox

Namespace
Avalonia.Controls
Assembly
Avalonia.Controls.dll

Viewbox is used to scale single child to fit in the available space.

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

Constructors

Viewbox()

Initializes a new instance of the Viewbox class.

public Viewbox()

Fields

ChildProperty

Defines the Child property

public static readonly StyledProperty<Control?> ChildProperty

Field Value

StyledProperty<Control>

StretchDirectionProperty

Defines the StretchDirection property.

public static readonly StyledProperty<StretchDirection> StretchDirectionProperty

Field Value

StyledProperty<StretchDirection>

StretchProperty

Defines the Stretch property.

public static readonly StyledProperty<Stretch> StretchProperty

Field Value

StyledProperty<Stretch>

Properties

Child

Gets or sets the child of the Viewbox

[Content]
public Control? Child { get; set; }

Property Value

Control

Stretch

Gets or sets the stretch mode, which determines how child fits into the available space.

public Stretch Stretch { get; set; }

Property Value

Stretch

StretchDirection

Gets or sets a value controlling in what direction contents will be stretched.

public StretchDirection StretchDirection { get; set; }

Property Value

StretchDirection

Methods

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.

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.

OnPropertyChanged(AvaloniaPropertyChangedEventArgs)

Called when a avalonia property changes on the object.

protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)

Parameters

change AvaloniaPropertyChangedEventArgs

The property change details.