영어로 읽기 편집

다음을 통해 공유


Size Struct

Definition

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

[System.ComponentModel.TypeConverter(typeof(System.Windows.SizeConverter))]
[System.Serializable]
public struct Size : IFormattable
[System.ComponentModel.TypeConverter(typeof(System.Windows.SizeConverter))]
public struct Size : IFormattable
Inheritance
Attributes
Implements

Examples

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

protected override Size MeasureOverride(Size availableSize)
{
    Size panelDesiredSize = new Size();

    // In our example, we just have one child. 
    // Report that our panel requires just the size of its only child.
    foreach (UIElement child in InternalChildren)
    {
        child.Measure(availableSize);
        panelDesiredSize = child.DesiredSize;
    }

    return panelDesiredSize ;
}

Remarks

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.

XAML Attribute Usage

<object property="width,height"/>  

XAML Values

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

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

Constructors

Size(Double, Double)

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

Properties

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.

Methods

Equals(Object)

Compares an object to an instance of Size for equality.

Equals(Size, Size)

Compares two instances of Size for equality.

Equals(Size)

Compares a value to an instance of Size for equality.

GetHashCode()

Gets the hash code for this instance of Size.

Parse(String)

Returns an instance of Size from a converted String.

ToString()

Returns a String that represents this Size object.

ToString(IFormatProvider)

Returns a String that represents this instance of Size.

Operators

Equality(Size, Size)

Compares two instances of Size for equality.

Explicit(Size to Point)

Explicitly converts an instance of Size to an instance of Point.

Explicit(Size to Vector)

Explicitly converts an instance of Size to an instance of Vector.

Inequality(Size, Size)

Compares two instances of Size for inequality.

Explicit Interface Implementations

IFormattable.ToString(String, IFormatProvider)

This type or member supports the Windows Presentation Foundation (WPF) infrastructure and is not intended to be used directly from your code.

Applies to

제품 버전
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

See also