Size structure

Applies to Windows and Windows Phone

Represents an ordered pair of floating-point numbers that specify a height and width.

Syntax


public value struct Size


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

XAML Values

width

A numeric value greater than or equal to 0 that specifies the Width component of the Size structure.

height

A numeric value greater than or equal to 0 that specifies the Height of the Size structure.

Attributes

[Version(0x06020000)]

Members

The Size structure has these types of members:

Constructors

The Size structure has these constructors.

ConstructorDescription
Size(Double, Double) [C#, VB]Initializes a new instance of the Size structure and assigns it an initial width and height.
Size(float, float) [C++, JavaScript]Initializes a new instance of the Size structure and assigns it an initial width and height.

 

Fields

The Size structure has these fields.

FieldData typeDescription
Height | height [C++, JavaScript]

Number [JavaScript] | System.Single [.NET] | float32 [C++]

The height.

Width | width [C++, JavaScript]

Number [JavaScript] | System.Single [.NET] | float32 [C++]

The width.

 

Methods

The Size structure has these methods. With C#, Visual Basic, and C++, it also inherits methods from the Object class.

MethodDescription
Equals(Object) [C#, VB]Determines whether the specified object is equal to a Size.
Equals(Rect) [C#, VB]Compares two Size structures for equality.
GetHashCode [C#, VB]Gets a hash code for this object.
ToString [C#, VB]Converts a Size to a String representation.

 

Operators

The Size structure has these operators.

OperatorDescription
Equality Compares two Size structures for equality.
Inequality Compares two Size structures for inequality.

 

Properties

The Size structure has these properties.

PropertyAccess typeDescription

Empty

Read-onlyGets a value that represents a static empty Size.

Height

Read/writeGets or sets the height of this instance of Size.

IsEmpty

Read-onlyGets a value that indicates whether this instance of Size is Empty.

Width

Read/writeGets or sets the width of this instance of Size.

 

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 two data properties: width and height. The APIs listed in the Size members lists don't apply to JavaScript programming.

Notes on XAML syntax

The only Windows Runtime property that uses a Size as a value in a XAML scenario 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 isn't typical. A Size can't be used as a XAML resource.

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.

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

Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8

Namespace

Windows.Foundation
Windows::Foundation [C++]

Metadata

Platform.winmd
Windows.winmd

See also

Rect
SizeHelper

 

 

Show:
© 2014 Microsoft