Size Struktura
Definicja
public value class Size : IFormattable
[System.ComponentModel.TypeConverter(typeof(System.Windows.SizeConverter))]
public struct Size : IFormattable
[System.ComponentModel.TypeConverter(typeof(System.Windows.SizeConverter))]
[System.Serializable]
public struct Size : IFormattable
[<System.ComponentModel.TypeConverter(typeof(System.Windows.SizeConverter))>]
type Size = struct
interface IFormattable
[<System.ComponentModel.TypeConverter(typeof(System.Windows.SizeConverter))>]
[<System.Serializable>]
type Size = struct
interface IFormattable
Public Structure Size
Implements IFormattable
- Dziedziczenie
- Atrybuty
- Implementuje
Przykłady
Poniższy przykład ilustruje sposób użycia Size struktury w kodzie.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
Uwagi
Size jest szczególnie przydatna, ponieważ opisuje zarówno Height obiekt, jak i Width .Size is particularly useful because it describes both the Height and Width of an object. Size jest szeroko używany przez system układu do rozmieszczenia i mierzenia elementów.Size is used extensively by the layout system to arrange and measure elements.
Użycie atrybutu języka XAMLXAML Attribute Usage
<object property="width,height"/>
Wartości XAMLXAML Values
Szerokośćwidth
Wartość większa lub równa 0, która określa Width Size strukturę.A value greater than or equal to 0 that specifies the Width of the Size structure.
proporcjheight
Wartość większa lub równa 0, która określa Height Size strukturę.A value greater than or equal to 0 that specifies the Height of the Size structure.
Konstruktory
Size(Double, Double) |
Inicjuje nowe wystąpienie Size struktury i przypisuje je początkową |
Właściwości
Empty |
Pobiera wartość, która reprezentuje statycznie pustą Size .Gets a value that represents a static empty Size. |
Height |
Pobiera lub ustawia wartość Height tego wystąpienia Size .Gets or sets the Height of this instance of Size. |
IsEmpty |
Pobiera wartość wskazującą, czy to wystąpienie Size jest Empty .Gets a value that indicates whether this instance of Size is Empty. |
Width |
Pobiera lub ustawia wartość Width tego wystąpienia Size .Gets or sets the Width of this instance of Size. |
Metody
Equals(Object) |
Porównuje obiekt z wystąpieniem Size dla równości.Compares an object to an instance of Size for equality. |
Equals(Size) |
Porównuje wartość z wystąpieniem Size dla równości.Compares a value to an instance of Size for equality. |
Equals(Size, Size) |
Porównuje dwa wystąpienia Size dla równości.Compares two instances of Size for equality. |
GetHashCode() |
Pobiera kod skrótu dla tego wystąpienia Size .Gets the hash code for this instance of Size. |
Parse(String) |
Zwraca wystąpienie Size z przekonwertowanego elementu String .Returns an instance of Size from a converted String. |
ToString() |
Zwraca wartość String reprezentującą ten Size obiekt.Returns a String that represents this Size object. |
ToString(IFormatProvider) |
Zwraca wartość String reprezentującą to wystąpienie Size .Returns a String that represents this instance of Size. |
Operatory
Equality(Size, Size) |
Porównuje dwa wystąpienia Size dla równości.Compares two instances of Size for equality. |
Explicit(Size to Point) |
Jawnie konwertuje wystąpienie Size do wystąpienia Point .Explicitly converts an instance of Size to an instance of Point. |
Explicit(Size to Vector) |
Jawnie konwertuje wystąpienie Size do wystąpienia Vector .Explicitly converts an instance of Size to an instance of Vector. |
Inequality(Size, Size) |
Porównuje dwa wystąpienia Size dla nierówności.Compares two instances of Size for inequality. |
Jawne implementacje interfejsu
IFormattable.ToString(String, IFormatProvider) |
Ten typ lub element członkowski obsługuje Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) infrastrukturę i nie jest przeznaczony do użycia bezpośrednio w kodzie.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. |