Skip to main content

Size Struct

Definition

Namespace:Avalonia
Assembly:Avalonia.Base
Package:Avalonia
Source:Size.cs

Defines a size.

public struct Size

Inheritance: ValueType -> Size

Implements: IEquatable<Size>

Constructors

NameDescription
Size (2 overloads)Initializes a new instance of the Avalonia.Size structure.

Size overloads

Size Constructor

Initializes a new instance of the Avalonia.Size structure.

public Size(double width, double height)
Parameters

width double

The width.

height double

The height.

Size Constructor

Initializes a new instance of the Avalonia.Size structure.

public Size(System.Numerics.Vector2 vector2)
Parameters

vector2 System.Numerics.Vector2

The vector to take values from.

Methods

NameDescription
ConstrainConstrains the size.
DeconstructNo summary available.
DeflateDeflates the size by a Avalonia.Thickness.
Equals (2 overloads)Returns a boolean indicating whether the size is equal to the other given size (bitwise).
GetHashCodeReturns a hash code for a Avalonia.Size.
InflateInflates the size by a Avalonia.Thickness.
NearlyEqualsReturns a boolean indicating whether the size is equal to the other given size (numerically).
ParseParses a Avalonia.Size string.
ToStringReturns the string representation of the size.
WithHeightReturns a new Avalonia.Size with the same width and the specified height.
WithWidthReturns a new Avalonia.Size with the same height and the specified width.

Constrain Method

Constrains the size.

public Avalonia.Size Constrain(Avalonia.Size constraint)

Parameters

constraint Avalonia.Size

The size to constrain to.

Returns

Avalonia.Size

The constrained size.

Deconstruct Method

public void Deconstruct(double& width, double& height)

Parameters

width double&

height double&

Deflate Method

Deflates the size by a Avalonia.Thickness.

public Avalonia.Size Deflate(Avalonia.Thickness thickness)

Parameters

thickness Avalonia.Thickness

The thickness.

Returns

Avalonia.Size

The deflated size.

Remarks

The deflated size cannot be less than 0.

Equals overloads

Equals Method

Returns a boolean indicating whether the size is equal to the other given size (bitwise).

public bool Equals(Avalonia.Size other)
Parameters

other Avalonia.Size

The other size to test equality against.

Returns

bool

True if this size is equal to other; False otherwise.

Equals Method

Checks for equality between a size and an object.

public bool Equals(object obj)
Parameters

obj object

The object.

Returns

bool

True if obj is a size that equals the current size.

GetHashCode Method

Returns a hash code for a Avalonia.Size.

public int GetHashCode()

Returns

int

The hash code.

Inflate Method

Inflates the size by a Avalonia.Thickness.

public Avalonia.Size Inflate(Avalonia.Thickness thickness)

Parameters

thickness Avalonia.Thickness

The thickness.

Returns

Avalonia.Size

The inflated size.

NearlyEquals Method

Returns a boolean indicating whether the size is equal to the other given size (numerically).

public bool NearlyEquals(Avalonia.Size other)

Parameters

other Avalonia.Size

The other size to test equality against.

Returns

bool

True if this size is equal to other; False otherwise.

Parse Method

Parses a Avalonia.Size string.

public Avalonia.Size Parse(string s)

Parameters

s string

The string.

Returns

Avalonia.Size

The Avalonia.Size.

ToString Method

Returns the string representation of the size.

public string ToString()

Returns

string

The string representation of the size.

WithHeight Method

Returns a new Avalonia.Size with the same width and the specified height.

public Avalonia.Size WithHeight(double height)

Parameters

height double

The height.

Returns

Avalonia.Size

The new Avalonia.Size.

WithWidth Method

Returns a new Avalonia.Size with the same height and the specified width.

public Avalonia.Size WithWidth(double width)

Parameters

width double

The width.

Returns

Avalonia.Size

The new Avalonia.Size.

Properties

NameDescription
AspectRatioGets the aspect ratio of the size.
HeightGets the height.
WidthGets the width.

AspectRatio Property

Gets the aspect ratio of the size.

public double AspectRatio { get; set; }

Height Property

Gets the height.

public double Height { get; set; }

Width Property

Gets the width.

public double Width { get; set; }

Fields

NameDescription
InfinityA size representing infinity.

Infinity Field

A size representing infinity.

public Avalonia.Size Infinity