Elements Property (Layout)
Find an element on a layout
//Find an element on a layout.
// Reference a layout project item by name
LayoutProjectItem layoutItem = Project.Current.GetItems<LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals("MyLayout"));
if (layoutItem != null)
{
QueuedTask.Run(() =>
{
// Reference and load the layout associated with the layout item
Layout mylayout = layoutItem.GetLayout();
if (mylayout != null)
{
//Find a single specific element
Element rect = mylayout.FindElement("Rectangle") as Element;
//Or use the Elements collection
Element rect2 = mylayout.Elements.FirstOrDefault(item => item.Name.Equals("Rectangle"));
}
});
}
Target Platforms: Windows 11, Windows 10
ArcGIS Pro version: 3 or higher.