Size Structure
Définition
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
- Héritage
- Attributs
- Implémente
Exemples
L’exemple suivant montre comment utiliser une structure Size dans le code.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
Remarques
Size est particulièrement utile, car il décrit à la fois les Height et Width d’un objet.Size is particularly useful because it describes both the Height and Width of an object. Size est largement utilisé par le système de disposition pour organiser et mesurer des éléments.Size is used extensively by the layout system to arrange and measure elements.
Utilisation d'attributs XAMLXAML Attribute Usage
<object property="width,height"/>
Valeurs XAMLXAML Values
widthwidth
Valeur supérieure ou égale à 0 qui spécifie le Width de la structure Size.A value greater than or equal to 0 that specifies the Width of the Size structure.
heightheight
Valeur supérieure ou égale à 0 qui spécifie le Height de la structure Size.A value greater than or equal to 0 that specifies the Height of the Size structure.
Constructeurs
Size(Double, Double) |
Initialise une nouvelle instance de la structure Size et lui attribue une |
Propriétés
Empty |
Obtient une valeur qui représente un Size vide statique.Gets a value that represents a static empty Size. |
Height |
Obtient ou définit la Height de cette instance de Size.Gets or sets the Height of this instance of Size. |
IsEmpty |
Obtient une valeur qui indique si cette instance de Size est Empty.Gets a value that indicates whether this instance of Size is Empty. |
Width |
Obtient ou définit la Width de cette instance de Size.Gets or sets the Width of this instance of Size. |
Méthodes
Equals(Object) |
Compare si un objet et une instance de Size sont égaux.Compares an object to an instance of Size for equality. |
Equals(Size) |
Compare une valeur à une instance de Size pour l'égalité.Compares a value to an instance of Size for equality. |
Equals(Size, Size) |
Compare l'égalité de deux instances de Size.Compares two instances of Size for equality. |
GetHashCode() |
Obtient le code de hachage pour cette instance de Size.Gets the hash code for this instance of Size. |
Parse(String) |
Retourne une instance de Size d'un String converti.Returns an instance of Size from a converted String. |
ToString() |
Retourne un String qui représente cet objet Size.Returns a String that represents this Size object. |
ToString(IFormatProvider) |
Retourne un String qui représente cette instance de Size.Returns a String that represents this instance of Size. |
Opérateurs
Equality(Size, Size) |
Compare l'égalité de deux instances de Size.Compares two instances of Size for equality. |
Explicit(Size to Point) |
Convertit une instance de Size en une instance de Point de manière explicite.Explicitly converts an instance of Size to an instance of Point. |
Explicit(Size to Vector) |
Convertit une instance de Size en une instance de Vector de manière explicite.Explicitly converts an instance of Size to an instance of Vector. |
Inequality(Size, Size) |
Compare l'inégalité de deux instances de Size.Compares two instances of Size for inequality. |
Implémentations d’interfaces explicites
IFormattable.ToString(String, IFormatProvider) |
Ce type ou membre prend en charge l’infrastructure Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) et n’est pas destiné à être utilisé directement à partir de votre code.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. |