ArcGIS Pro 2.7 API Reference Guide
SetObject Method
Example 

ArcGIS.Desktop.Mapping Namespace > StyleItem Class : SetObject Method
The object from which style item's properties are populated
Sets the properties of the style item equal to the object passed as argument. This method must be called on the MCT. Use QueuedTask.Run.
Syntax
public void SetObject( 
   object itemObject
)
Public Sub SetObject( _
   ByVal itemObject As Object _
) 

Parameters

itemObject
The object from which style item's properties are populated
Exceptions
ExceptionDescription
This method must be called within the lambda passed to QueuedTask.Run
Example
//Creates a new style item and sets its properties from an existing style item
public Task<StyleItem> CreateNewStyleItemAsync(StyleItem existingItem)
{
  if (existingItem == null)
    throw new System.ArgumentNullException();

  return QueuedTask.Run(() =>
  {
    StyleItem item = new StyleItem();

    //Get object from existing style item
    object obj = existingItem.GetObject();

    //New style item's properties are set from the existing item
    item.SetObject(obj);

    //Key, Name, Tags and Category for the new style item have to be set
    //These values are NOT populated from the object passed in to SetObject
    item.Key = "KeyOfTheNewItem";
    item.Name = "NameOfTheNewItem";
    item.Tags = "TagsForTheNewItem";
    item.Category = "CategoryOfTheNewItem";

    return item;
  });
}
Requirements

Target Platforms: Windows 10, Windows 8.1

See Also

Reference

StyleItem Class
StyleItem Members