ArcGIS Pro 3.4 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 Version

AddItem Method (StyleHelper)
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
)

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

ArcGIS Pro version: 3 or higher.
See Also