VisualTreeHelper.GetTransform(Visual) 메서드

정의

TransformVisual 값을 반환합니다.

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

매개 변수

reference
Visual

변환 값이 반환되는 Visual입니다.

반환

Transform

Visual의 변환 값이고, reference에 변환이 정의되어 있지 않으면 null입니다.

예제

다음 코드 예제에서는 메서드를 사용 하 여 GetTransform 지정 된 시각적 개체에 대 한 변환을 검색 하는 방법을 보여 있습니다.

// Return the transform for the specified visual object.
Transform transform = VisualTreeHelper.GetTransform(myDrawing);

// If there is no transform defined for the object, the return value is null.
if (transform != null)
{
    // Return the offset of the returned transform. The offset is relative to the parent of the visual object.
    Point pt = transform.Transform(new Point(0, 0));
}
' Return the transform for the specified visual object.
Dim transform As Transform = VisualTreeHelper.GetTransform(myDrawing)

' If there is no transform defined for the object, the return value is null.
If transform IsNot Nothing Then
    ' Return the offset of the returned transform. The offset is relative to the parent of the visual object.
    Dim pt As Point = transform.Transform(New Point(0, 0))
End If

반환된 값을 사용하기 전에 코드에서 테스트 null 해야 합니다. 반환된 변환의 오프셋을 반환하려면 메서드를 Transform 사용합니다. 오프셋 값은 .의 부모를 기준으로 합니다 Visual.

설명

또는 메서드를 TransformToAncestor 사용하여 상위 항목에 Visual대한 변환 값을 반환할 수 있습니다. 이 메서드는 항상 유효한 변환을 반환합니다. 다음 코드 예제에서는 메서드를 사용하는 TransformToAncestor 방법을 보여줍니다.

// Return the general transform for the specified visual object.
GeneralTransform generalTransform1 = myTextBlock.TransformToAncestor((Visual)myTextBlock.Parent);

// Retrieve the point value relative to the parent.
Point currentPoint = generalTransform1.Transform(new Point(0, 0));
' Return the general transform for the specified visual object.
Dim generalTransform1 As GeneralTransform = myTextBlock.TransformToAncestor(CType(myTextBlock.Parent, Visual))

' Retrieve the point value relative to the parent.
Dim currentPoint As Point = generalTransform1.Transform(New Point(0, 0))

적용 대상