Describes the width and height of an object.
Assembly: System.Windows (in System.Windows.dll)
'Declaration Public Structure Size
public struct Size
A numeric value greater than or equal to 0 that specifies the Width of the Size structure.
A numeric value greater than or equal to 0 that specifies the Height of the Size structure.
In the XAML syntax, the width-height delimiter can be either a space or comma. A Size value uses an internal type converter to process the string value.
See Remarks for additional information on value constraints that apply both to XAML and to code.
The Size type exposes the following members.
|Size||Initializes a new instance of the Size structure and assigns it an initial width and height.|
|Empty||Gets a value that represents a static empty Size.|
|Height||Gets or sets the height of this instance of Size.|
|IsEmpty||Gets a value that indicates whether this instance of Size is Empty.|
|Width||Gets or sets the width of this instance of Size.|
|Equals(Object)||Compares an object to an instance of Size for equality. (Overrides ValueType.Equals(Object).)|
|Equals(Size)||Compares a value to an instance of Size for equality.|
|Finalize||Allows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)|
|GetHashCode||Gets the hash code for this instance of Size. (Overrides ValueType.GetHashCode().)|
|GetType||Gets the Type of the current instance. (Inherited from Object.)|
|MemberwiseClone||Creates a shallow copy of the current Object. (Inherited from Object.)|
|ToString||Returns a string representation of this Size. (Overrides ValueType.ToString().)|
|Equality||Compares two instances of Size for equality.|
|Inequality||Compares two instances of Size for inequality.|
Dimensions of 0 are permitted by the Size structure, but might not be permitted when interpreted or validated by particular properties that take a Size. Check documentation for the specific property you are setting for possible details on Size property constraints. In general, the values of a Size can be greater than or equal to 0.
The programmatic upper limit for values is not PositiveInfinity, it is a lower number (approximately 1,000,000) that is enforced by the Silverlight native code.
Rect is a similar structure that uses the same metaphor of specifying a height and width. However, a Rect specifies an origin point, whereas a Size does not. In general, Rect is used for APIs that relate to graphical presentation at a lower level, and Size is used for APIs that relate to UI presentation and layout.
In contrast to other structures such as Thickness, the XAML attribute syntax for Size does not support a symmetric mode that takes only one value applied to both width and height. For instance the following will generate a parser error: <ArcSegment Size="50"/>.
Negative values for height or width of a Size are not permitted.
Properties of Size do not support an attribute syntax in XAML for Silverlight. In XAML you should always specify Size-type properties through one of the following usages:
The XAML attribute usage, which infers properties that use the Size type and uses a type converter to process the attribute string into the specific values for the Size.
A property element usage, containing a Size object element. For that object element, set the Size properties using initialization text, as shown in the XAML Object Element Usage.
If you specify a Size for use as a resource, use the object element usage and set the Size properties using initialization text.
Size is available as a valid object in the managed API for Silverlight.
Supported in: 5, 4, 3
Silverlight for Windows Phone
Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.