ArcGIS Pro 2.9 API Reference Guide
SetAnnotationProperties Method
Example 

ArcGIS.Desktop.Editing.Attributes Namespace > Inspector Class : SetAnnotationProperties Method
a set of annotation properties to be applied.
Sets annotation properties on annotation features within the inspector. This method must be called on the MCT. Uses QueuedTask.Run.
Syntax
public void SetAnnotationProperties( 
   AnnotationProperties annotationProperties
)
Public Sub SetAnnotationProperties( _
   ByVal annotationProperties As AnnotationProperties _
) 

Parameters

annotationProperties
a set of annotation properties to be applied.
Exceptions
ExceptionDescription
This method or property must be called within the lambda passed to QueuedTask.Run.
Example
await QueuedTask.Run(() =>
{
  //annoLayer is ~your~ Annotation layer...

  // use the inspector methodology
  var insp = new Inspector(true);
  insp.Load(annoLayer, oid);

  // get the annotation properties
  AnnotationProperties annoProperties = insp.GetAnnotationProperties();
  // set the attribute
  annoProperties.TextString = "Hello World";
  // assign the annotation proeprties back to the inspector
  insp.SetAnnotationProperties(annoProperties);

  //create and execute the edit operation
  EditOperation op = new EditOperation();
  op.Name = "Update annotation";
  op.Modify(insp);
  op.Execute();
});
await QueuedTask.Run(() =>
{
  //Don't use 'Shape'....Shape is the bounding box of the annotation text. This is NOT what you want...
  //
  //var insp = new Inspector();
  //insp.Load(annoLayer, oid);
  //var shape = insp["SHAPE"] as Polygon;
  //...wrong shape...

  //Instead, we must use the AnnotationProperties

  //annoLayer is ~your~ Annotation layer
  var insp = new Inspector(true);
  insp.Load(annoLayer, oid);

  AnnotationProperties annoProperties = insp.GetAnnotationProperties();
  var shape = annoProperties.Shape;
  if (shape.GeometryType != GeometryType.GeometryBag)
  {
    var newGeometry = GeometryEngine.Instance.Move(shape, 10, 10);
    annoProperties.Shape = newGeometry;
    insp.SetAnnotationProperties(annoProperties);

    EditOperation op = new EditOperation();
    op.Name = "Change annotation angle";
    op.Modify(insp);
    op.Execute();
  }
});
await QueuedTask.Run(() =>
{

  var selection = annoLayer.GetSelection();
  if (selection.GetCount() == 0)
    return;

  // use the first selelcted feature 
  var insp = new Inspector(true);
  insp.Load(annoLayer, selection.GetObjectIDs().FirstOrDefault());

  // getAnnoProperties should return null if not an annotation feature
  AnnotationProperties annoProperties = insp.GetAnnotationProperties();
  // get the textGraphic
  CIMTextGraphic textGraphic = annoProperties.TextGraphic;

  // change text
  textGraphic.Text = "Hello world";

  // set x,y offset via the symbol
  var symbol = textGraphic.Symbol.Symbol;
  var textSymbol = symbol as CIMTextSymbol;
  textSymbol.OffsetX = 2;
  textSymbol.OffsetY = 3;

  textSymbol.HorizontalAlignment = HorizontalAlignment.Center;

  // load the updated textGraphic
  annoProperties.LoadFromTextGraphic(textGraphic);
  // assign the annotation properties back 
  insp.SetAnnotationProperties(annoProperties);

  EditOperation op = new EditOperation();
  op.Name = "modify symbol";
  op.Modify(insp);
  bool result = op.Execute();
});
Requirements

Target Platforms: Windows 11, Windows 10, Windows 8.1

See Also

Reference

Inspector Class
Inspector Members