Size Struct

Definition

Represents number values that specify a height and width.

public value class Size
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.FoundationContract, 65536)]
struct Size
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.FoundationContract), 65536)]
public struct Size
var size = {
width : /* Your value */,
height : /* Your value */
}
Public Structure Size
<object property="width,height"/>
-or-
<object property="width height"/>
Inheritance
Size
Attributes

Windows requirements

Device family
Windows 10 (introduced in 10.0.10240.0)
API contract
Windows.Foundation.FoundationContract (introduced in v1.0)

Remarks

When applied to properties that represent UI information, the width and height values of a Size value represent device-independent pixels.

JavaScript In JavaScript, a Size is an object with 2 data properties: width and height. The API listed in the Size member lists don't apply to JavaScript programming.

Notes on XAML syntax

The only Windows Runtime property that uses a Size as a value for XAML is ArcSegment.Size. Rect is more common.

Object attribute usage is technically permitted by the Windows Runtime XAML parsing rules. However, that usage isn't shown in syntax because it's not common. A Size can't be used as a XAML resource (for more info see ResourceDictionary and XAML resource references).

You can use a space rather than a comma as the delimiter between values.

Projection and members of Size

If you are using a Microsoft .NET language (C# or Microsoft Visual Basic), or Visual C++ component extensions (C++/CX), then Size has non-data members available, and its data members are exposed as read-write properties, not fields. See Size in the .NET API Browser.

If you are programming with C++/WinRT or the Windows Runtime C++ Template Library (WRL), then only the data member fields exist as members of Size, and you cannot use the utility methods or properties of the .NET projection. C++ code can access similar utility methods that are available from the SizeHelper static class.

This table shows the equivalent methods available in .NET and C++.

.NET (Size) C++ (SizeHelper)
Size(Double, Double) FromDimensions(Single, Single)
Empty Empty
IsEmpty GetIsEmpty(Size)
Equals Equals(Size, Size)

Fields

Height

The height.

Width

The width.

Applies to

See also