ArcGIS Pro 3.8 API Reference Guide
ArcGIS.Desktop.Layouts Namespace / IGraphicFactory Interface / CreateLegendPatchGraphic Method
The legend patch shape
The extent of the graphic element
The symbol to be used with the graphic (optional)
Example

In This Topic
    CreateLegendPatchGraphic Method (IGraphicFactory)
    In This Topic
    Create a polygon or line graphic of the specified ArcGIS.Core.CIM.PatchShape using the provided extent and symbol
    Syntax
    Function CreateLegendPatchGraphic( _
       ByVal patchShape As PatchShape, _
       ByVal extent As Envelope, _
       Optional ByVal patchSymbol As CIMSymbol _
    ) As CIMGraphic

    Parameters

    patchShape
    The legend patch shape
    extent
    The extent of the graphic element
    patchSymbol
    The symbol to be used with the graphic (optional)

    Return Value

    Example
    Create Legend Patch Graphic
    {
      await QueuedTask.Run(() =>
      {
    
      //Build geometry
      List<Coordinate2D> plyCoords = new List<Coordinate2D>();
      plyCoords.Add(new Coordinate2D(1, 1));
      plyCoords.Add(new Coordinate2D(1.25, 2));
      plyCoords.Add(new Coordinate2D(1.5, 1.1));
      plyCoords.Add(new Coordinate2D(1.75, 2));
      plyCoords.Add(new Coordinate2D(2, 1.1));
      plyCoords.Add(new Coordinate2D(2.25, 2));
      plyCoords.Add(new Coordinate2D(2.5, 1.1));
      plyCoords.Add(new Coordinate2D(2.75, 2));
      plyCoords.Add(new Coordinate2D(3, 1));
      Polygon poly = PolygonBuilderEx.CreatePolygon(plyCoords);
    
      //Set symbology, create and add element to layout
      CIMStroke outline = SymbolFactory.Instance.ConstructStroke(
                ColorFactory.Instance.BlackRGB, 2.0, SimpleLineStyle.Solid);
      CIMPolygonSymbol polySym = SymbolFactory.Instance.ConstructPolygonSymbol(
                ColorFactory.Instance.RedRGB, SimpleFillStyle.ForwardDiagonal, outline);
    
      var graphic = GraphicFactory.Instance.CreateLegendPatchGraphic(
                  PatchShape.AreaBoundary, poly.Extent, polySym);
    
      //Make an element to add to GraphicsLayer or Layout
      //
      //var elemInfo = new ElementInfo()
      //{
      //  CustomProperties = null,
      //  Anchor = Anchor.LeftMidPoint
      //};
      //var ge = ElementFactory.Instance.CreateGraphicElement(layout, graphic,
        //  "New Legend Patch", true, elemInfo);
      });
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also