This documentation is archived and is not being maintained.

Size Structure

Implements a structure that is used to describe the Size of an object.

Namespace:  System.Windows
Assembly:  WindowsBase (in WindowsBase.dll)

public value class Size : IFormattable
<object property="width,height"/>

XAML Values


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


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

The Size type exposes the following members.

Public methodSizeInitializes a new instance of the Size structure and assigns it an initial width and height.

Public propertyStatic memberEmptyGets a value that represents a static empty Size.
Public propertyHeightGets or sets the Height of this instance of Size.
Public propertyIsEmptyGets a value that indicates whether this instance of Size is Empty.
Public propertyWidthGets or sets the Width of this instance of Size.

Public methodEquals(Object)Compares an object to an instance of Size for equality. (Overrides ValueType::Equals(Object).)
Public methodEquals(Size)Compares a value to an instance of Size for equality.
Public methodStatic memberEquals(Size, Size)Compares two instances of Size for equality.
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeGets the hash code for this instance of Size. (Overrides ValueType::GetHashCode().)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodStatic memberParseReturns an instance of Size from a converted String.
Public methodToString()Returns a String that represents this Size object. (Overrides ValueType::ToString().)
Public methodToString(IFormatProvider)Returns a String that represents this instance of Size.

Public operatorStatic memberEqualityCompares two instances of Size for equality.
Public operatorStatic memberExplicit(Size to Vector)Explicitly converts an instance of Size to an instance of Vector.
Public operatorStatic memberExplicit(Size to Point)Explicitly converts an instance of Size to an instance of Point.
Public operatorStatic memberInequalityCompares two instances of Size for inequality.

Explicit interface implemetationPrivate methodIFormattable::ToStringThis type or member supports the Windows Presentation Foundation (WPF) infrastructure and is not intended to be used directly from your code.

Size is particularly useful because it describes both the Height and Width of an object. Size is used extensively by the layout system to arrange and measure elements.

The following example demonstrates how to use a Size structure in code.

         virtual Size MeasureOverride(Size availableSize) override
             Size^ panelDesiredSize = gcnew Size();

             // In our example, we just have one child. 
             // Report that our panel requires just the size of its only child.
             for each (UIElement^ child in InternalChildren)
				 panelDesiredSize = child->DesiredSize;
             return *panelDesiredSize ;

More Code

How to: Create an Elliptical ArcThis example shows how to draw an elliptical arc. To create an elliptical arc, use the PathGeometry, PathFigure, and ArcSegment classes.

.NET Framework

Supported in: 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.