ArcGIS Pro 3.3 API Reference Guide
ArcGIS.Desktop.Layouts Namespace / Element Class / SetAnchorPoint Method
The new anchor point location
Example

In This Topic
    SetAnchorPoint Method (Element)
    In This Topic
    Sets the element anchor point to the X and Y location specified. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    public void SetAnchorPoint( 
       Coordinate2D anchorPoint
    )
    Public Sub SetAnchorPoint( _
       ByVal anchorPoint As Coordinate2D _
    ) 

    Parameters

    anchorPoint
    The new anchor point location
    Exceptions
    ExceptionDescription
    This method must be called within the lambda passed to QueuedTask.Run.
    This element requires its mapview to be active
    Remarks
    Placement for an element contained in graphics layer requires the mapview be active.
    . Use SetX and SetY to change the anchor point X and Y individually. Changing the element anchor point location does not change its anchor position relative to its element. Anchor position is modified via SetAnchor.
    Example
    Move Graphic Elements
    //Each selected element will move to a set distance to the upper right.
    var selElements = graphicsLayer.GetSelectedElements();
    if (selElements.Count == 0) return;
    //Move the element up
    foreach (var selElement in selElements)
    {
      //Get the element's bounds
      var elementPoly = PolygonBuilderEx.CreatePolygon(selElement.GetBounds());
      //get the coordinates of the element bounding envelope.
      var pointsList = elementPoly.Copy2DCoordinatesToList();
      //Move the element's Anchor point to the upper right.
      selElement.SetAnchorPoint(pointsList[1]);
    }
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also