Visual.TransformToDescendant(Visual) メソッド

定義

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

パラメーター

descendant
Visual

座標の変換先となる Visual

戻り値

GeneralTransform

GeneralTransform 型の値。

例外

descendantnullです。

ビジュアルは、descendant ビジュアルの先祖ではありません。

ビジュアル オブジェクトは相対的ではありません。

次のマークアップの例は、StackPanel オブジェクト内に含まれる TextBlock を示しています。

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

次のコード例は、TransformToDescendant メソッドを使用して、その子 TextBlock に対する StackPanel の相対的なオフセットを取得する方法を示します。 オフセット値は、返された GeneralTransform 値内に含まれます。

// 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 値が考慮されます。 この場合、X は -4 で、Y は -4 です。 親オブジェクトは子オブジェクトに対して負のオフセットであるため、オフセット値は負の値です。

適用対象