ArcGIS Pro 2.7 API Reference Guide
Legend Class
Members  Example 

ArcGIS.Desktop.Layouts Namespace : Legend Class
Represents a legend element on a page layout.
Object Model
Legend ClassElement ClassCoordinate2D StructureEnvelope ClassCIMElement ClassIElementParent InterfaceMapFrame Class
Syntax
Remarks
There are currently no additional members but this class can be used to determine the type of MapSurround and element may be.
Example
//Create a legend for an associated map frame.

//Construct on the worker thread
await QueuedTask.Run(() =>
{
  //Build 2D envelope geometry
  Coordinate2D leg_ll = new Coordinate2D(6, 2.5);
  Coordinate2D leg_ur = new Coordinate2D(8, 4.5);
  Envelope leg_env = EnvelopeBuilder.CreateEnvelope(leg_ll, leg_ur);

  //Reference MF, create legend and add to layout
  MapFrame mapFrame = layout.FindElement("New Map Frame") as MapFrame;
  if (mapFrame == null)
  {
    ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Map frame not found", "WARNING");
    return;
  }
  Legend legendElm = LayoutElementFactory.Instance.CreateLegend(layout, leg_env, mapFrame);
  legendElm.SetName("New Legend");
});
Inheritance Hierarchy

System.Object
   ArcGIS.Desktop.Framework.Contracts.PropertyChangedBase
      ArcGIS.Desktop.Layouts.Element
         ArcGIS.Desktop.Layouts.MapSurround
            ArcGIS.Desktop.Layouts.Legend

Requirements

Target Platforms: Windows 10, Windows 8.1

See Also

Reference

Legend Members
ArcGIS.Desktop.Layouts Namespace