ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / StyleItemType Enumeration
Example Example

In This Topic
    StyleItemType Enumeration
    In This Topic
    Specifies the type of StyleItem.
    Syntax
    Members
    MemberDescription
    AreaLegendPatch An area legend patch, small rectangles used to display legend classes.
    Color A single color defined by values in a supported color model.
    ColorRamp An array of colors in a specified pattern or scheme.
    DimensionStyle A style used to draw Dimension features.
    Grid A grid layout element.
    Legend A legend layout element.
    LegendItem A legend item layout element.
    LineLegendPatch A line legend patch, small lines used to display legend classes
    LineSymbol A symbol to draw line features.
    MaplexLabelPlacement A set of rules based on the Maplex label engine determining how labels will be placed in relation to features.
    MapSurround A map surround layout element (excludes surrounds with their own type e.g. North Arrow).
    MeshSymbol A symbol to draw multipatch features.
    NorthArrow A directional layout element used to indicate north orientation.
    PointSymbol A symbol to draw point features.
    PolygonSymbol A symbol to draw polygon features.
    ScaleBar A layout element that graphically indicates map scale.
    StandardLabelPlacement A set of rules based on the standard label engine determining how labels will be placed in relation to features.
    TableFrame A table frame layout element.
    TableFrameField A table frame field layout element.
    TextSymbol A symbol to draw labels or annotation features.
    Unknown A generic, unspecified style item.
    Remarks
    StyleItem class.
    Example
    Create Line Element
    //Must be on QueuedTask.Run(() => { ...
    
    //Build geometry
    List<Coordinate2D> plCoords = new List<Coordinate2D>();
    plCoords.Add(new Coordinate2D(1, 8.5));
    plCoords.Add(new Coordinate2D(1.66, 9));
    plCoords.Add(new Coordinate2D(2.33, 8.1));
    plCoords.Add(new Coordinate2D(3, 8.5));
    Polyline linePl = PolylineBuilderEx.CreatePolyline(plCoords);
    
    //Reference a line symbol in a style
    var ProjectStyles = Project.Current.GetItems<StyleProjectItem>();
    StyleProjectItem style = ProjectStyles.First(x => x.Name == "ArcGIS 2D");
    var symStyle = style.SearchSymbols(StyleItemType.LineSymbol, "Line with 2 Markers")[0];
    CIMLineSymbol lineSym = symStyle.Symbol as CIMLineSymbol;
    lineSym.SetSize(20);
    
    //Set symbology, create and add element to layout
    //CIMLineSymbol lineSym = SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.BlueRGB, 4.0, SimpleLineStyle.Solid);
    ElementFactory.Instance.CreateGraphicElement(
      container, linePl, lineSym, "New Line");
    
    Create Point Element
    //Must be on QueuedTask.Run(() => { ...
    
    //Build geometry
    Coordinate2D coord2D = new Coordinate2D(2.0, 10.0);
    
    //Reference a point symbol in a style
    StyleProjectItem stylePrjItm = Project.Current.GetItems<StyleProjectItem>()
             .FirstOrDefault(item => item.Name == "ArcGIS 2D");
    SymbolStyleItem symStyleItm = stylePrjItm.SearchSymbols(
                          StyleItemType.PointSymbol, "City Hall")[0];
    CIMPointSymbol pointSym = symStyleItm.Symbol as CIMPointSymbol;
    pointSym.SetSize(50);
    
    var elemInfo = new ElementInfo()
    {
      CustomProperties = new List<CIMStringMap>() {
         new CIMStringMap() { Key = "Key1", Value = "Value1"},
         new CIMStringMap() { Key = "Key2", Value = "Value2"}
       },
      Anchor = Anchor.TopRightCorner,
      Rotation = 45.0
    };
    
    var graphic = GraphicFactory.Instance.CreateSimpleGraphic(
                                  coord2D.ToMapPoint(), pointSym);
    
    ElementFactory.Instance.CreateGraphicElement(
      container, graphic, "New Point", true, elemInfo);
    
    How to apply a point symbol from a style to a feature layer
      // var map = MapView.Active.Map;
      // if (map == null)
      //        return;
      // var pointFeatureLayer =
      //       map.GetLayersAsFlattenedList()
      //          .OfType<FeatureLayer>()
      //         .Where(fl => fl.ShapeType == esriGeometryType.esriGeometryPoint);
      //   await ApplySymbolToFeatureLayerAsync(pointFeatureLayer.FirstOrDefault(), "Fire Station");
    
      public Task ApplySymbolToFeatureLayerAsync(FeatureLayer featureLayer, string symbolName)
      {
        return QueuedTask.Run(async () =>
        {
          //Get the ArcGIS 2D System style from the Project
          var arcGIS2DStyle =
    Project.Current.GetItems<StyleProjectItem>().FirstOrDefault(s => s.Name == "ArcGIS 2D");
    
          //Search for the symbolName style items within the ArcGIS 2D style project item.
          var items = await QueuedTask.Run(() =>
          arcGIS2DStyle.SearchSymbols(StyleItemType.PointSymbol, symbolName));
    
          //Gets the CIMSymbol
          CIMSymbol symbol = items.FirstOrDefault().Symbol;
    
          //Get the renderer of the point feature layer
          CIMSimpleRenderer renderer = featureLayer.GetRenderer() as CIMSimpleRenderer;
    
          //Set symbol's real world setting to be the same as that of the feature layer
          symbol.SetRealWorldUnits(featureLayer.UsesRealWorldSymbolSizes);
    
          //Apply the symbol to the feature layer's current renderer
          renderer.Symbol = symbol.MakeSymbolReference();
    
          //Apply the renderer to the feature layer
          featureLayer.SetRenderer(renderer);
        });
      }
    Inheritance Hierarchy

    System.Object
       System.ValueType
          System.Enum
             ArcGIS.Desktop.Mapping.StyleItemType

    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also