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

Użycie atrybutu języka XAML

<object property="width,height"/>  

Wartości XAML

width
Wartość większa lub równa 0, która określa Width Size strukturę.

height
Wartość większa lub równa 0, która określa Height Size strukturę.

Konstruktory

Size(Double, Double)

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

Właściwości

Empty

Pobiera wartość reprezentującą statyczną pustą Sizewartość .

Height

Pobiera lub ustawia Height to wystąpienie klasy Size.

IsEmpty

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

Width

Pobiera lub ustawia Width to wystąpienie klasy Size.

Metody

Equals(Object)

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

Equals(Size)

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

Equals(Size, Size)

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

GetHashCode()

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

Parse(String)

Zwraca wystąpienie z Size przekonwertowanego Stringobiektu .

ToString()

Zwraca obiekt String reprezentujący ten Size obiekt.

ToString(IFormatProvider)

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

Operatory

Equality(Size, Size)

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

Explicit(Size to Point)

Jawnie konwertuje wystąpienie wystąpienia Size na wystąpienie klasy Point.

Explicit(Size to Vector)

Jawnie konwertuje wystąpienie wystąpienia Size na wystąpienie klasy Vector.

Inequality(Size, Size)

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

Jawne implementacje interfejsu

IFormattable.ToString(String, IFormatProvider)

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

Dotyczy

Zobacz też