ArcGIS Pro 3.1 API Reference Guide
ArcGIS.Desktop.Layouts Namespace / LayoutView Class
Members Example

In This Topic
    LayoutView Class
    In This Topic
    Represents the view of layout in a pane.
    Object Model
    LayoutView ClassMapFrame ClassMapView ClassLayoutView ClassIElementContainer InterfaceMapFrame ClassCoordinate2D StructureEnvelope ClassLayout ClassCoordinate2D Structure
    Syntax
    public sealed class LayoutView 
    Public NotInheritable Class LayoutView 
    Remarks

    A project can contain multiple layouts. A layout view is a pane that displays the view of a layout. Layout views are the primary interface used to display, navigate, and select layout elements. The layout being visualized in the view can be accessed via the Layout property.

    There can be multiple layout views open at a given time, but there can only be one active layout view. The active layout view will set the context for the ribbon and many of the dock panes in the application. The Active property will return null if there is no active layout view.

    The layout view has several "ZoomTo" nagivation methods and it also provides the context for managing selected items in the Contents pane. For example, the GetSelectedElements method returns a collection of selected page layout elements.

    Example
    Reference the active layout view
    //Reference the active layout view.
    
    //Confirm if the current, active view is a layout view.
    //If it is, do something.
    LayoutView activeLayoutView = LayoutView.Active;
    if (activeLayoutView != null)
    {
      // do something
    }
    Get element selection count
    //Get element's selection count.
    
    //Count the number of selected elements on the active layout view
    LayoutView activeLayoutView = LayoutView.Active;
    if (activeLayoutView != null)
    {
      var selectedElements = activeLayoutView.GetSelectedElements();
      ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show($@"Selected elements: {selectedElements.Count}");
    }
    Set element selection
    //Set the active layout view's selection to include 2 rectangle elements.
    
    //Reference the active view 
    LayoutView activeLayoutView = LayoutView.Active;
    if (activeLayoutView != null)
    {
    
      //Perform on the worker thread
      QueuedTask.Run(() =>
      {
    
        //Reference the layout
        Layout lyt = activeLayoutView.Layout;
    
        //Reference the two rectangle elements
        Element rec = lyt.FindElement("Rectangle");
        Element rec2 = lyt.FindElement("Rectangle 2");
    
        //Construct a list and add the elements
        List<Element> elmList = new List<Element>
        {
          rec,
          rec2
        };
    
        //Set the selection
        activeLayoutView.SelectElements(elmList);
      });
    }
    Inheritance Hierarchy

    System.Object
       ArcGIS.Desktop.Layouts.LayoutView

    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.0 or higher.
    See Also