Size Size Size Size Size Struct


Represents number values that specify a height and width.

public : struct Size
struct winrt::Windows::Foundation::Size
public struct Size
Public Structure Size
var size = {

   height: /* Your value */,

   width: /* Your value */

<object property="width,height"/>
<object property="width height"/>

Windows 10 requirements

Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.FoundationContract (introduced v1)


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)


Height Height Height Height Height

The height.

Width Width Width Width Width

The width.

See also