Size Struct
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
[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
- Inheritance
- Attributes
- Implements
Examples
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
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 |
Properties
Empty |
Gets a value that represents a static empty Size. |
Height | |
IsEmpty |
Gets a value that indicates whether this instance of Size is Empty. |
Width |
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) | |
ToString() | |
ToString(IFormatProvider) |
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. |