ArcGIS Pro 2.7 API Reference Guide
CreateMapFrame(ILayoutElementContainer,Polygon,Map) Method
Example 

ArcGIS.Desktop.Layouts Namespace > LayoutElementFactory Class > CreateMapFrame Method : CreateMapFrame(ILayoutElementContainer,Polygon,Map) Method
Layout or GroupElement
Polygon
Map
Creates a map frame element on a layout from an polygon geometry. This method must be called on the MCT. Use QueuedTask.Run.
Syntax
Public Overloads Function CreateMapFrame( _
   ByVal elementContainer As ILayoutElementContainer, _
   ByVal polygon As Polygon, _
   Optional ByVal map As Map _
) As MapFrame

Parameters

elementContainer
Layout or GroupElement
polygon
Polygon
map
Map

Return Value

Returns a MapFrame.
Exceptions
ExceptionDescription
This method or property must be called within the lambda passed to QueuedTask.Run.
Map has reached maximum graphics count limit of 4000 elements. One or more elements cannot be created.
Map has reached maximum graphics size limit of 10 MB. One or more elements cannot be created.
Remarks
If the element container is a Layout then the element gets added to the root level of the layout TOC at the top most position. If the element container is a GroupElement then it gets added to the group at the topmost position.
Example
//Create a map frame and set its camera by zooming to the extent of an existing bookmark.

//Construct on the worker thread
await QueuedTask.Run(() =>
{
  //Build 2D envelope geometry
  Coordinate2D mf_ll = new Coordinate2D(6.0, 8.5);
  Coordinate2D mf_ur = new Coordinate2D(8.0, 10.5);
  Envelope mf_env = EnvelopeBuilder.CreateEnvelope(mf_ll, mf_ur);

  //Reference map, create MF and add to layout
  MapProjectItem mapPrjItem = Project.Current.GetItems<MapProjectItem>().FirstOrDefault(item => item.Name.Equals("Map"));
  Map mfMap = mapPrjItem.GetMap();
  MapFrame mfElm = LayoutElementFactory.Instance.CreateMapFrame(layout, mf_env, mfMap);
  mfElm.SetName("New Map Frame");

  //Zoom to bookmark
  Bookmark bookmark = mfElm.Map.GetBookmarks().FirstOrDefault(b => b.Name == "Great Lakes");
  mfElm.SetCamera(bookmark);
});
Requirements

Target Platforms: Windows 10, Windows 8.1

See Also

Reference

LayoutElementFactory Class
LayoutElementFactory Members
Overload List