ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Desktop.Core.Events Namespace / ProjectWindowSelectedItemsChangedEvent Class
Members Example

In This Topic
    ProjectWindowSelectedItemsChangedEvent Class
    In This Topic
    Occurs when the selection changes in either the Project dockpane ("Catalog pane") or any Project pane instance ("Catalog view").
    Object Model
    ProjectWindowSelectedItemsChangedEvent ClassSubscriptionToken ClassSubscriptionToken Class
    Syntax
    public sealed class ProjectWindowSelectedItemsChangedEvent : ArcGIS.Core.Events.CompositePresentationEvent<ProjectWindowSelectedItemsChangedEventArgs> 
    Public NotInheritable Class ProjectWindowSelectedItemsChangedEvent 
       Inherits ArcGIS.Core.Events.CompositePresentationEvent(Of ProjectWindowSelectedItemsChangedEventArgs)
    Remarks
    The project window that triggered the selection change can be accessed via the ProjectWindowSelectedItemsChangedEventArgs passed to your event subscriber's action.
    Example
    Geodatabase Content from Catalog selection
    // subscribe to event
    ProjectWindowSelectedItemsChangedEvent.Subscribe(async (ProjectWindowSelectedItemsChangedEventArgs args) =>
    {
      if (args.IProjectWindow.SelectionCount > 0)
      {
        // get the first selected item
        var selectedItem = args.IProjectWindow.SelectedItems.First();
    
        await QueuedTask.Run(() =>
        {
          // datasetType
          var dataType = ItemFactory.Instance.GetDatasetType(selectedItem);
    
          // get the dataset Definition
          if (ItemFactory.Instance.CanGetDefinition(selectedItem))
          {
            using (var def = ItemFactory.Instance.GetDefinition(selectedItem))
            {
              if (def is ArcGIS.Core.Data.FeatureClassDefinition fcDef)
              {
                var oidField = fcDef.GetObjectIDField();
                var shapeField = fcDef.GetShapeField();
                var shapeType = fcDef.GetShapeType();
              }
              else if (def is ArcGIS.Core.Data.Parcels.ParcelFabricDefinition pfDef)
              {
                string ver = pfDef.GetSchemaVersion();
                bool enabled = pfDef.GetTopologyEnabled();
              }
    
              // etc
            }
          }
    
          // get the dataset
          if (ItemFactory.Instance.CanGetDataset(selectedItem))
          {
            using (var ds = ItemFactory.Instance.GetDataset(selectedItem))
            {
              if (ds is ArcGIS.Core.Data.FeatureDataset fds)
              {
                // open featureclasses within the feature dataset
                // var fcPoint = fds.OpenDataset<FeatureClass>("Point");
                // var fcPolyline = fds.OpenDataset<FeatureClass>("Polyline");
              }
              else if (ds is FeatureClass fc)
              {
                var name = fc.GetName() + "_copy";
    
                // create
                var featureLayerParams = new FeatureLayerCreationParams(fc)
                {
                  Name = name,
                  MapMemberIndex = 0
                };
                LayerFactory.Instance.CreateLayer<FeatureLayer>(featureLayerParams, MapView.Active.Map);
              }
              else if (ds is Table table)
              {
                var name = table.GetName() + "_copy";
                var tableParams = new StandaloneTableCreationParams(table)
                {
                  Name = name
                };
                // create
                StandaloneTableFactory.Instance.CreateStandaloneTable(tableParams, MapView.Active.Map);
              }
            }
          }
        });
      }
    });
    Inheritance Hierarchy

    System.Object
       ArcGIS.Core.Events.EventBase
          ArcGIS.Core.Events.CompositePresentationEvent<TPayload>
             ArcGIS.Desktop.Core.Events.ProjectWindowSelectedItemsChangedEvent

    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also