ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Desktop.Layouts Namespace / PictureElement Class
Members Example

In This Topic
    PictureElement Class
    In This Topic
    Represents a picture element on a page layout.
    Object Model
    PictureElement ClassGraphicElement ClassCoordinate2D StructureEnvelope ClassCIMElement ClassGeometry ClassCIMGraphic ClassIElementContainer Interface
    Syntax
    Remarks
    A PictureElement is a type of GraphicElement and therefore can be positioned or resized on the page. Picture elements are embedded in the project file (.aprx) but the SourcePath property will return the original source file source path. You can change the picture by using the SetSourcePath method along with a new file path.
    Example
    PictureElement_SetSourcePath
    LayoutProjectItem layoutItem = Project.Current.GetItems<LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals("Layout Name"));
    await QueuedTask.Run(() => 
    {
      Layout layout = layoutItem.GetLayout();
      PictureElement picElm = layout.FindElement("Rectangle") as PictureElement;
    
      picElm.SetSourcePath(@"C:\Some\New\Path\And\file_pic.png");
    });
    PictureElementExample
    ///This example references a PictureElement on a layout and changes the picture by setting a path to a file on disk using the
    
    //Added references
    using ArcGIS.Desktop.Core;
    using ArcGIS.Desktop.Layouts;
    using ArcGIS.Desktop.Framework.Threading.Tasks;
    
    public class PictureElementExample
    {
      public static Task<bool> UpdatePictureElementAsync(string LayoutName, string PictureName, string PicturePath)
      {
        //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 picture element by name
          PictureElement picElm = lyt.FindElement(PictureName) as PictureElement;
          if (picElm == null)
            return false;
    
          //Change the path to a new source
          picElm.SetSourcePath(PicturePath);
    
          return true;
        });
      }
    }
    Update a picture element
    //Update a picture element.
    
    //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 picture element by name
        PictureElement picElm = layout.FindElement("MyPicture") as PictureElement;
        // Change the path to a new source
        if (picElm != null)
          picElm.SetSourcePath(@"D:\MyData\Pics\somePic.jpg");
      }
    });
    Inheritance Hierarchy

    System.Object
       ArcGIS.Desktop.Framework.Contracts.PropertyChangedBase
          ArcGIS.Desktop.Layouts.Element
             ArcGIS.Desktop.Layouts.GraphicElement
                ArcGIS.Desktop.Layouts.PictureElement

    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also