Visual.TransformToDescendant Method
Assembly: PresentationCore (in presentationcore.dll)
public GeneralTransform TransformToDescendant ( Visual descendant )
public function TransformToDescendant ( descendant : Visual ) : GeneralTransform
You cannot use methods in XAML.
Parameters
- descendant
The Visual to which the coordinates are transformed.
Return Value
A value of type GeneralTransform.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>
The following code example shows how to use the TransformToDescendant method to retrieve the offset of the StackPanel relative to its child TextBlock. 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));
The offset takes into account the Margin values for all objects. In this case, X is -4, and Y is -4. The offset values are negative values, since the parent object is negatively offset relative to its child object.
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.