Size Size Size Size Struct

定義

實作用來描述 Size 物件的結構。Implements a structure that is used to describe the Size of an object.

public value class Size : IFormattable
[System.ComponentModel.TypeConverter(typeof(System.Windows.SizeConverter))]
[System.Serializable]
public struct Size : IFormattable
type Size = struct
    interface IFormattable
Public Structure Size
Implements IFormattable
繼承
屬性
實作

範例

下列範例示範如何在程式碼中Size使用結構。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)
        {
            child->Measure(availableSize);
panelDesiredSize = child->DesiredSize;
        }
        return *panelDesiredSize ;
    }
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 ;
}
Protected Overrides Function MeasureOverride(ByVal availableSize As System.Windows.Size) As System.Windows.Size
    Dim panelDesiredSize As Size = New Size()
    ' In our example, we just have one child. 
    ' Report that our panel requires just the size of its only child.
    For Each child As UIElement In InternalChildren
        child.Measure(availableSize)
        panelDesiredSize = child.DesiredSize
    Next
    Return panelDesiredSize
End Function

備註

Size特別有用, 因為它同時描述物件HeightWidth和。Size is particularly useful because it describes both the Height and Width of an object. Size版面配置系統會廣泛使用來排列和測量元素。Size is used extensively by the layout system to arrange and measure elements.

XAML Attribute UsageXAML Attribute Usage

<object property="width,height"/>  

XAML 值XAML Values

widthwidth
大於或等於0的值, 指定Width Size結構的。A value greater than or equal to 0 that specifies the Width of the Size structure.

高寬比height
大於或等於0的值, 指定Height Size結構的。A value greater than or equal to 0 that specifies the Height of the Size structure.

建構函式

Size(Double, Double) Size(Double, Double) Size(Double, Double) Size(Double, Double)

初始化 Size 結構的新執行個體,並對其指派初始 widthheightInitializes a new instance of the Size structure and assigns it an initial width and height.

屬性

Empty Empty Empty Empty

取得值,表示靜態的空 SizeGets a value that represents a static empty Size.

Height Height Height Height

取得或設定這個 Height 執行個體的 SizeGets or sets the Height of this instance of Size.

IsEmpty IsEmpty IsEmpty IsEmpty

取得值,表示 Size 的這個執行個體是否為 EmptyGets a value that indicates whether this instance of Size is Empty.

Width Width Width Width

取得或設定這個 Width 執行個體的 SizeGets or sets the Width of this instance of Size.

方法

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

比較物件與 Size 執行個體是否相等。Compares an object to an instance of Size for equality.

Equals(Size) Equals(Size) Equals(Size) Equals(Size)

比較值與 Size 執行個體是否相等。Compares a value to an instance of Size for equality.

Equals(Size, Size) Equals(Size, Size) Equals(Size, Size) Equals(Size, Size)

比較 Size 的兩個執行個體是否相等。Compares two instances of Size for equality.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

取得 Size 之這個執行個體的雜湊程式碼。Gets the hash code for this instance of Size.

Parse(String) Parse(String) Parse(String) Parse(String)

從轉換的 Size 傳回 String 的執行個體。Returns an instance of Size from a converted String.

ToString() ToString() ToString() ToString()

傳回 String,表示這個 Size 物件。Returns a String that represents this Size object.

ToString(IFormatProvider) ToString(IFormatProvider) ToString(IFormatProvider) ToString(IFormatProvider)

傳回 String,表示 Size 的這個執行個體。Returns a String that represents this instance of Size.

運算子

Equality(Size, Size) Equality(Size, Size) Equality(Size, Size) Equality(Size, Size)

比較 Size 的兩個執行個體是否相等。Compares two instances of Size for equality.

Explicit(Size to Point) Explicit(Size to Point) Explicit(Size to Point) Explicit(Size to Point)

Size 的執行個體明確轉換成 Point 的執行個體。Explicitly converts an instance of Size to an instance of Point.

Explicit(Size to Vector) Explicit(Size to Vector) Explicit(Size to Vector) Explicit(Size to Vector)

Size 的執行個體明確轉換成 Vector 的執行個體。Explicitly converts an instance of Size to an instance of Vector.

Inequality(Size, Size) Inequality(Size, Size) Inequality(Size, Size) Inequality(Size, Size)

比較 Size 的兩個執行個體是否不相等。Compares two instances of Size for inequality.

明確介面實作

IFormattable.ToString(String, IFormatProvider) IFormattable.ToString(String, IFormatProvider) IFormattable.ToString(String, IFormatProvider) IFormattable.ToString(String, IFormatProvider)

這個類型或成員支援 Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) 基礎結構,而且不能從程式碼直接使用。This type or member supports the Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) infrastructure and is not intended to be used directly from your code.

適用於

另請參閱