ArcGIS Pro 3.0 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / StyleHelper Class / AddItem Method
The StyleProjectItem to which StyleItem will be added.
The StyleItem to be added.
Example

In This Topic
    AddItem Method (StyleHelper)
    In This Topic
    Adds a style item to a style. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    public static void AddItem( 
       StyleProjectItem styleProjectItem,
       StyleItem item
    )
    Public Shared Sub AddItem( _
       ByVal styleProjectItem As StyleProjectItem, _
       ByVal item As StyleItem _
    ) 

    Parameters

    styleProjectItem
    The StyleProjectItem to which StyleItem will be added.
    item
    The StyleItem to be added.
    Exceptions
    ExceptionDescription
    This method must be called within the lambda passed to QueuedTask.Run
    Adding an item cannot be performed on a read-only style.
    The item could not be added to the style. The key may not be unique.
    Example
    How to add a style item to a style
    public Task AddStyleItemAsync(StyleProjectItem style, StyleItem itemToAdd)
    {
      return QueuedTask.Run(() =>
      {
        if (style == null || itemToAdd == null)
          throw new System.ArgumentNullException();
    
        //Add the item to style
        style.AddItem(itemToAdd);
      });
    }
    Requirements

    Target Platforms: Windows 11, Windows 10, Windows 8.1

    See Also