Returns the offset of the
public static Vector GetOffset(
The returned offset value is relative to the parent of the
. If you want to return an offset value that is not relative to the parent of a Visual , use the Visual method. TransformToAncestor
The following markup example shows a
that is defined with TextBlock value of 4. Margin
< TextBlock Name = " myTextBlock " Margin = " 4 " Text = " Hello, world " />
The following code example shows how to use the
method to retrieve the offset of the GetOffset . The offset values are contained within the returned TextBlock value. 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);
The offset takes into account the
value. In this case, Margin is 4, and X is 4. Y .NET Framework
Supported in: 4, 3.5, 3.0
.NET Framework Client Profile
Supported in: 4, 3.5 SP1
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see
.NET Framework System Requirements.