VisualTreeHelper.GetOffset(Visual) 메서드

정의

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

매개 변수

reference
Visual

오프셋이 반환되는 Visual입니다.

반환

Vector

Vector의 오프셋 값을 나타내는 Visual입니다.

예제

다음 태그 예제에서는 값이 4로 Margin 정의된 것을 보여 TextBlock 줍니다.

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

다음 코드 예제에서는 메서드를 사용하여 GetOffset 오프셋을 TextBlock검색하는 방법을 보여줍니다. 오프셋 값은 반환 Vector 된 값 내에 포함됩니다.

// 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)

오프셋은 값을 고려합니다 Margin . 이 경우 X 4이고 4 Y 입니다.

설명

반환된 오프셋 값은 .의 부모를 기준으로 합니다 Visual. 부모에 상대적이지 않은 오프셋 값을 반환하려면 메서드를 VisualTransformToAncestor 사용합니다.

적용 대상