Visual.TransformToDescendant(Visual) 메서드
정의
public:
System::Windows::Media::GeneralTransform ^ TransformToDescendant(System::Windows::Media::Visual ^ descendant);
public System.Windows.Media.GeneralTransform TransformToDescendant (System.Windows.Media.Visual descendant);
member this.TransformToDescendant : System.Windows.Media.Visual -> System.Windows.Media.GeneralTransform
Public Function TransformToDescendant (descendant As Visual) As GeneralTransform
매개 변수
반환
GeneralTransform 형식의 값입니다.A value of type GeneralTransform.
예외
descendant
이(가) null
인 경우descendant
is null
.
시각적 개체가 descendant
시각적 개체의 상위 항목이 아닌 경우The visual is not an ancestor of the descendant
visual.
시각적 개체가 관련되지 않은 경우The visual objects are not related.
예제
다음 태그 예제에서는 개체에 포함 된를 보여 줍니다 TextBlock StackPanel .The following markup example shows a TextBlock that is contained within a StackPanel object.
<StackPanel Name="myStackPanel" Margin="8">
<TextBlock Name="myTextBlock" Margin="4" Text="Hello, world" />
</StackPanel>
다음 코드 예제에서는 메서드를 사용 하 여 TransformToDescendant 자식에 상대적인의 오프셋을 검색 하는 방법을 보여 줍니다 StackPanel TextBlock .The following code example shows how to use the TransformToDescendant method to retrieve the offset of the StackPanel relative to its child TextBlock. 오프셋 값은 반환 된 값에 포함 됩니다 GeneralTransform .The offset values are contained within the returned GeneralTransform value.
// Return the general transform for the specified visual object.
GeneralTransform generalTransform1 = myStackPanel.TransformToDescendant(myTextBlock);
// Retrieve the point value relative to the child.
Point currentPoint = generalTransform1.Transform(new Point(0, 0));
' Return the general transform for the specified visual object.
Dim generalTransform1 As GeneralTransform = myStackPanel.TransformToDescendant(myTextBlock)
' Retrieve the point value relative to the child.
Dim currentPoint As Point = generalTransform1.Transform(New Point(0, 0))
오프셋은 Margin 모든 개체에 대 한 값을 고려 합니다.The offset takes into account the Margin values for all objects. 이 경우은 X -4이 고 Y 은-4입니다.In this case, X is -4, and Y is -4. 부모 개체가 자식 개체에 상대적으로 오프셋 되어 있으므로 오프셋 값은 음수 값입니다.The offset values are negative values because the parent object is negatively offset relative to its child object.