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 셋이 반환되는 값입니다.

반품

의 오프셋 값을 나타내는 A VectorVisual입니다.

예제

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

<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이고 Y 4입니다.

설명

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

적용 대상