ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / KnowledgeGraphLayer Class / MoveLayer Method / MoveLayer(Layer,CompositeLayer,Int32) Method
A Layer to be moved.
The layer container to move the layer to.
The position specified by the 0-based index. -1 will move the table to the bottom of the specified container. If the index is invalid, the layer is moved to the bottom.
Version

MoveLayer(Layer,CompositeLayer,Int32) Method
Move a layer to another position within the specified container. This method must be called on the MCT. Use QueuedTask.Run.
Syntax
public void MoveLayer( 
   Layer layer,
   CompositeLayer targetLayer,
   int position
)

Parameters

layer
A Layer to be moved.
targetLayer
The layer container to move the layer to.
position
The position specified by the 0-based index. -1 will move the table to the bottom of the specified container. If the index is invalid, the layer is moved to the bottom.
Exceptions
ExceptionDescription
The layer or targetLayer is null.
Invalid container. The layer is not part of this container or one of it's descendents.
This method or property must be called within the lambda passed to QueuedTask.Run.
Remarks
The layer must already be part of this container or one of it's descendents. To move the layer to the root of the TOC use Map.MoveLayer. To move the layer into a group layer from the root of the TOC use Map.MoveLayer.
Requirements

Target Platforms: Windows 11, Windows 10

ArcGIS Pro version: 3.4 or higher.
See Also