Size 结构

定义

实现一个结构,该结构用于描述对象的 SizeImplements 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
继承
属性
实现

示例

下面的示例演示如何在代码中使用 @no__t 的结构。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 特别有用,因为它描述了对象的 @no__t 1 和 @no__t 2。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 属性用法XAML Attribute Usage

<object property="width,height"/>  

XAML 值XAML Values

widthwidth
一个大于或等于0的值,指定 Size 结构的 @no__t。A value greater than or equal to 0 that specifies the Width of the Size structure.

height
一个大于或等于0的值,指定 Size 结构的 @no__t。A value greater than or equal to 0 that specifies the Height of the Size structure.

构造函数

Size(Double, Double)

初始化 Size 结构的新实例,并为其分配初始 widthheightInitializes a new instance of the Size structure and assigns it an initial width and height.

属性

Empty

获取一个值,该值表示空的静态 SizeGets a value that represents a static empty Size.

Height

获取或设置此 Height 实例的 SizeGets or sets the Height of this instance of Size.

IsEmpty

获取一个值,该值指示此 Size 实例是否为 EmptyGets a value that indicates whether this instance of Size is Empty.

Width

获取或设置此 Width 实例的 SizeGets or sets the Width of this instance of Size.

方法

Equals(Object)

比较某个对象与 Size 的实例是否相等。Compares an object to an instance of Size for equality.

Equals(Size)

比较某个值与 Size 的实例是否相等。Compares a value to an instance of Size for equality.

Equals(Size, Size)

比较 Size 的两个实例是否相等。Compares two instances of Size for equality.

GetHashCode()

获取 Size 的此实例的哈希代码。Gets the hash code for this instance of Size.

Parse(String)

从转换后的 Size 返回 String 的实例。Returns an instance of Size from a converted String.

ToString()

返回一个表示此 String 对象的 SizeReturns a String that represents this Size object.

ToString(IFormatProvider)

返回一个表示此 String 实例的 SizeReturns a String that represents this instance of Size.

操作员

Equality(Size, Size)

比较 Size 的两个实例是否相等。Compares two instances of Size for equality.

Explicit(Size to Point)

Size 的实例显式转换为 Point 的实例。Explicitly converts an instance of Size to an instance of Point.

Explicit(Size to Vector)

Size 的实例显式转换为 Vector 的实例。Explicitly converts an instance of Size to an instance of Vector.

Inequality(Size, Size)

比较 Size 的两个实例是否不相等。Compares two instances of Size for inequality.

显式界面实现

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.

适用于

另请参阅