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 は、オブジェクトの HeightWidth の両方を記述するため、特に便利です。 Size は、要素の配置と測定にレイアウト システムによって広く使用されます。

XAML 属性の使用法

<object property="width,height"/>

XAML 値

Width構造体のSizeを指定する 0 以上の値。

高さHeight構造体のSizeを指定する 0 以上の値。

コンストラクター

名前 説明
Size(Double, Double)

Size構造体の新しいインスタンスを初期化し、初期widthheightを割り当てます。

プロパティ

名前 説明
Empty

静的な空の Sizeを表す値を取得します。

Height

HeightのこのインスタンスのSizeを取得または設定します。

IsEmpty

SizeのこのインスタンスがEmptyされているかどうかを示す値を取得します。

Width

WidthのこのインスタンスのSizeを取得または設定します。

メソッド

名前 説明
Equals(Object)

オブジェクトを Size のインスタンスと等しいかどうかを比較します。

Equals(Size, Size)

Sizeの 2 つのインスタンスを等しいかどうかを比較します。

Equals(Size)

値を Size のインスタンスと等しいかどうかを比較します。

GetHashCode()

Sizeのこのインスタンスのハッシュ コードを取得します。

Parse(String)

変換されたSizeからStringのインスタンスを返します。

ToString()

このString オブジェクトを表すSizeを返します。

ToString(IFormatProvider)

Stringのこのインスタンスを表すSizeを返します。

演算子

名前 説明
Equality(Size, Size)

Sizeの 2 つのインスタンスを等しいかどうかを比較します。

Explicit(Size to Point)

SizeのインスタンスをPointのインスタンスに明示的に変換します。

Explicit(Size to Vector)

SizeのインスタンスをVectorのインスタンスに明示的に変換します。

Inequality(Size, Size)

Sizeの 2 つのインスタンスの不等値を比較します。

明示的なインターフェイスの実装

名前 説明
IFormattable.ToString(String, IFormatProvider)

この型またはメンバーは、Windows Presentation Foundation (WPF) インフラストラクチャをサポートしており、コードから直接使用するためのものではありません。

適用対象

こちらもご覧ください