ArcGIS Pro 3.2 API Reference Guide
ArcGIS.Core.CIM Namespace / CIMGraphic Class / Transparency Property
Example

In This Topic
    Transparency Property (CIMGraphic)
    In This Topic
    Gets or sets the transparency of the graphic. Typically set by the layer or element during draw. Change the transparency of layers in the symbol for persistent changes.
    Syntax
    public double Transparency {get; set;}
    Public Property Transparency As Double
    Example
    CIMGraphic
    //This example references a graphic element on a layout and sets its Transparency property (which is not available in the managed API)
    //by accessing the element's CIMGraphic.
    
    //Added references
    using ArcGIS.Core.CIM;                             //CIM
    using ArcGIS.Desktop.Core;                         //Project
    using ArcGIS.Desktop.Layouts;                      //Layout class
    using ArcGIS.Desktop.Framework.Threading.Tasks;    //QueuedTask
    
    public class GraphicElementExample1
    {
      public static Task<bool> UpdateElementTransparencyAsync(string LayoutName, string ElementName, int TransValue)
      {
        //Reference a layoutitem in a project by name
        LayoutProjectItem layoutItem = Project.Current.GetItems<LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals(LayoutName));
        if (layoutItem == null)
          return Task.FromResult(false);
    
        return QueuedTask.Run<bool>(() =>
        {
          //Reference and load the layout associated with the layout item
          Layout lyt = layoutItem.GetLayout();
    
          //Reference a element by name
          GraphicElement graElm = lyt.FindElement(ElementName) as GraphicElement;
          if (graElm == null)
            return false;
    
          //Modify the Transparency property that exists only in the CIMGraphic class.
          CIMGraphic CIMGra = graElm.GetGraphic() as CIMGraphic;
          CIMGra.Transparency = TransValue;             //e.g., TransValue = 50
          graElm.SetGraphic(CIMGra);
    
          return true;
        });
      }
    }
    Update an elements transparency
    //Update an element's transparency using the CIM.
    
    //Perform on the worker thread
    QueuedTask.Run(() =>
    {
      // Reference and load the layout associated with the layout item
      Layout layout = layoutItem.GetLayout();
      if (layout != null)
      {
        // Reference a element by name
        GraphicElement graphicElement = layout.FindElement("MyElement") as GraphicElement;
        if (graphicElement != null)
        {
          // Modify the Transparency property that exists only in the CIMGraphic class.
          CIMGraphic CIMGraphic = graphicElement.GetGraphic() as CIMGraphic;
          CIMGraphic.Transparency = 50; // mark it 50% transparent
          graphicElement.SetGraphic(CIMGraphic);
        }
      }
    });
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also