ArcGIS Pro 3.2 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / StyleItem Class / SetObject Method
The object from which style item's properties are populated
Example

In This Topic
    SetObject Method
    In This Topic
    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
    GetSetObject
    //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 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also