Language
Edit

AspectRatio Struct

Definition

The AspectRatio structure is used by the ConstrainedBox control to define a specific ratio to restrict its content.

[Windows.Foundation.Metadata.CreateFromString(MethodName="CommunityToolkit.WinUI.Controls.AspectRatio.ConvertToAspectRatio")]
public readonly struct AspectRatio
[<Windows.Foundation.Metadata.CreateFromString(MethodName="CommunityToolkit.WinUI.Controls.AspectRatio.ConvertToAspectRatio")>]
type AspectRatio = struct
Public Structure AspectRatio
Inheritance
AspectRatio
Attributes
Windows.Foundation.Metadata.CreateFromStringAttribute

Constructors

Name Description
AspectRatio(Double, Double)

Initializes a new instance of the AspectRatio struct with the provided width and height.

AspectRatio(Double)

Initializes a new instance of the AspectRatio struct with the specific numerical aspect ratio.

Properties

Name Description
Height

Gets the height component of the aspect ratio.

Value

Gets the raw numerical aspect ratio value itself (Width / Height).

Width

Gets the width component of the aspect ratio or the aspect ratio itself (and height will be 1).

Methods

Name Description
ConvertToAspectRatio(String)

Converter to take a string aspect ration like "16:9" and convert it to an AspectRatio struct. Used automatically by XAML.

ToString()

Returns the fully qualified type name of this instance.

Operators

Name Description
Implicit(AspectRatio to Double)

Implicit conversion operator to convert an AspectRatio to a Double value. This lets you use them easily in mathematical expressions.

Implicit(Double to AspectRatio)

Implicit conversion operator to convert a Double to an AspectRatio value. This allows for x:Bind to bind to a double value.

Implicit(Int32 to AspectRatio)

Implicit conversion operator to convert a Int32 to an AspectRatio value. Creates a simple aspect ratio of N:1, where N is int

Applies to