Size 結構

定義

實作用來描述 Size 物件的結構。

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

範例

下列範例示範如何在程式碼中使用 Size 結構。

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 特別有用,因為它同時 Height 描述 物件的 和 WidthSize 配置系統廣泛使用來排列和測量元素。

XAML Attribute Usage

<object property="width,height"/>  

XAML 值

width (寬度)
大於或等於 0 的值,指定 Width Size 結構的 。

height (高度)
大於或等於 0 的值,指定 Height Size 結構的 。

建構函式

Size(Double, Double)

初始化 Size 結構的新執行個體,並對其指派初始 widthheight

屬性

Empty

取得值,表示靜態的空 Size

Height

取得或設定這個 Height 執行個體的 Size

IsEmpty

取得值,表示 Size 的這個執行個體是否為 Empty

Width

取得或設定這個 Width 執行個體的 Size

方法

Equals(Object)

比較物件與 Size 執行個體是否相等。

Equals(Size)

比較值與 Size 執行個體是否相等。

Equals(Size, Size)

比較 Size 的兩個執行個體是否相等。

GetHashCode()

取得這個 Size 執行個體的雜湊碼。

Parse(String)

從轉換的 Size 傳回 String 的執行個體。

ToString()

傳回 String,表示這個 Size 物件。

ToString(IFormatProvider)

傳回 String,表示 Size 的這個執行個體。

運算子

Equality(Size, Size)

比較 Size 的兩個執行個體是否相等。

Explicit(Size to Point)

Size 的執行個體明確轉換成 Point 的執行個體。

Explicit(Size to Vector)

Size 的執行個體明確轉換成 Vector 的執行個體。

Inequality(Size, Size)

比較 Size 的兩個執行個體是否不相等。

明確介面實作

IFormattable.ToString(String, IFormatProvider)

這個類型或成員支援 Windows Presentation Foundation (WPF) 基礎結構,而且不能從程式碼直接使用。

適用於

另請參閱