ArcGIS Pro 3.0 API Reference Guide
ArcGIS.Desktop.Catalog Namespace / OpenItemDialog Class
Members Example

In This Topic
    OpenItemDialog Class
    In This Topic
    Opens the Browse dialog box and allows you to select one or more project items, portal items, or items available from a local or network disk.
    Object Model
    OpenItemDialog ClassBrowseProjectFilter Class
    Syntax
    public sealed class OpenItemDialog : ItemDialog 
    Public NotInheritable Class OpenItemDialog 
       Inherits ItemDialog
    Example
    OpenItemDialog
    /// Adds a single item to a map
    OpenItemDialog addToMapDialog = new OpenItemDialog()
    {
      Title = "Add To Map",
      InitialLocation = @"C:\Data\NewYork\Counties\Erie\Streets",
      Filter = ItemFilters.Composite_AddToMap
    };
    
    BrowseDialogItems
    // cref: OpenItemDialog;ArcGIS.Desktop.Catalog.ItemDialog.Filter
    // cref: OpenItemDialog;ArcGIS.Desktop.Catalog.ItemDialog.InitialLocation
    // cref: OpenItemDialog;ArcGIS.Desktop.Catalog.ItemDialog.Title
    // cref: OpenItemDialog;ArcGIS.Desktop.Catalog.OpenItemDialog
    #region OpenItemDialog
    
    /// Adds a single item to a map
    OpenItemDialog addToMapDialog = new OpenItemDialog()
    {
      Title = "Add To Map",
      InitialLocation = @"C:\Data\NewYork\Counties\Erie\Streets",
      Filter = ItemFilters.Composite_AddToMap
    };
    
    Geodatabase Content from Browse Dialog
    var openDlg = new OpenItemDialog
    {
      Title = "Select a Feature Class",
      InitialLocation = @"C:\Data",
      MultiSelect = false,
      BrowseFilter = BrowseProjectFilter.GetFilter(ArcGIS.Desktop.Catalog.ItemFilters.GeodatabaseItems_All)
    };
    
    //show the browse dialog
    bool? ok = openDlg.ShowDialog();
    if (!ok.HasValue || openDlg.Items.Count() == 0)
      return;   //nothing selected
    
    await QueuedTask.Run(() =>
    {
      // get the item
      var item = openDlg.Items.First();
    
      // see if the item has a dataset
      if (ItemFactory.Instance.CanGetDataset(item))
      {
        // get it
        using (var ds = ItemFactory.Instance.GetDataset(item))
        {
          // access some properties
          var name = ds.GetName();
          var path = ds.GetPath();
    
          // if it's a featureclass
          if (ds is ArcGIS.Core.Data.FeatureClass fc)
          {
            // create a layer 
            var featureLayerParams = new FeatureLayerCreationParams(fc)
            {
              MapMemberIndex = 0
            };
            var layer = LayerFactory.Instance.CreateLayer<FeatureLayer>(featureLayerParams, MapView.Active.Map);
    
            // continue
          }
        }
      }
    });
    Inheritance Hierarchy

    System.Object
       ArcGIS.Desktop.Catalog.ItemDialog
          ArcGIS.Desktop.Catalog.OpenItemDialog

    Requirements

    Target Platforms: Windows 11, Windows 10, Windows 8.1

    See Also