VisualTreeHelper.GetOffset(Visual) Metoda

Definice

Vrátí posun hodnoty Visual.

public:
 static System::Windows::Vector GetOffset(System::Windows::Media::Visual ^ reference);
public static System.Windows.Vector GetOffset (System.Windows.Media.Visual reference);
static member GetOffset : System.Windows.Media.Visual -> System.Windows.Vector
Public Shared Function GetOffset (reference As Visual) As Vector

Parametry

reference
Visual

Jejíž Visual posun se vrátí.

Návraty

Vector

A Vector , který představuje hodnotu posunu Visual.

Příklady

Následující příklad revize ukazuje TextBlock , který je definován s Margin hodnotou 4.

<TextBlock Name="myTextBlock" Margin="4" Text="Hello, world" />

Následující příklad kódu ukazuje, jak použít metodu GetOffset k načtení posunu TextBlock. Hodnoty posunu jsou obsaženy v vrácené Vector hodnotě.

// Return the offset vector for the TextBlock object.
Vector vector = VisualTreeHelper.GetOffset(myTextBlock);

// Convert the vector to a point value.
Point currentPoint = new Point(vector.X, vector.Y);
' Return the offset vector for the TextBlock object.
Dim vector As Vector = VisualTreeHelper.GetOffset(myTextBlock)

' Convert the vector to a point value.
Dim currentPoint As New Point(vector.X, vector.Y)

Posun bere v úvahu Margin hodnotu. V tomto případě X je 4 a Y je 4.

Poznámky

Vrácená hodnota posunu je relativní k nadřazené hodnotě Visual. Pokud chcete vrátit hodnotu posunu, která není relativní vzhledem k nadřazené Visualsadě , použijte metodu TransformToAncestor .

Platí pro