Size Struktura

Definicja

Implementuje strukturę używaną do opisywania Size obiektu.

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
Dziedziczenie
Atrybuty
Implementuje

Przykłady

W poniższym przykładzie pokazano, jak używać Size struktury w kodzie.

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 obiekt , jak Height i Width . Size system układów jest szeroko używany do rozmieszczania i mierzenia elementów.

Użycie atrybutu XAML

<object property="width,height"/>

Wartości XAML

Szerokość Wartość większa lub równa 0, która określa WidthSize strukturę.

Wysokość Wartość większa lub równa 0, która określa HeightSize strukturę.

Konstruktory

Nazwa Opis
Size(Double, Double)

Inicjuje nowe wystąpienie Size struktury i przypisuje jej początkowe width i height.

Właściwości

Nazwa Opis
Empty

Pobiera wartość reprezentującą pusty Sizestatyczny element .

Height

Pobiera lub ustawia Height wartość tego wystąpienia klasy Size.

IsEmpty

Pobiera wartość wskazującą, czy to wystąpienie Size elementu to Empty.

Width

Pobiera lub ustawia Width wartość tego wystąpienia klasy Size.

Metody

Nazwa Opis
Equals(Object)

Porównuje obiekt z wystąpieniem Size równości.

Equals(Size, Size)

Porównuje dwa wystąpienia Size równości.

Equals(Size)

Porównuje wartość z wystąpieniem Size równości.

GetHashCode()

Pobiera kod skrótu dla tego wystąpienia programu Size.

Parse(String)

Zwraca wystąpienie klasy Size z przekonwertowanego Stringelementu .

ToString()

Zwraca obiekt String reprezentujący ten Size obiekt.

ToString(IFormatProvider)

Zwraca obiekt String reprezentujący to wystąpienie klasy Size.

Operatory

Nazwa Opis
Equality(Size, Size)

Porównuje dwa wystąpienia Size równości.

Explicit(Size to Point)

Jawnie konwertuje wystąpienie klasy Size na wystąpienie Pointklasy .

Explicit(Size to Vector)

Jawnie konwertuje wystąpienie klasy Size na wystąpienie Vectorklasy .

Inequality(Size, Size)

Porównuje Size dwa wystąpienia nierówności.

Jawne implementacje interfejsu

Nazwa Opis
IFormattable.ToString(String, IFormatProvider)

Ten typ lub element członkowski obsługuje infrastrukturę programu Windows Presentation Foundation (WPF) i nie jest przeznaczony do użycia bezpośrednio z kodu.

Dotyczy

Zobacz też