ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / MapView Class / ShowCustomPopup Method / ShowCustomPopup(IEnumerable<PopupContent>,IEnumerable<PopupCommand>,Boolean) Method
The content to be displayed in the pop-up.
The collection of commands to show at the bottom of the pop-up.
A value indicating if the default pop-up commands should display.
Example

In This Topic
    ShowCustomPopup(IEnumerable<PopupContent>,IEnumerable<PopupCommand>,Boolean) Method
    In This Topic
    Show a custom pop-up. This method must be called on the UI thread.
    Syntax

    Parameters

    popupContent
    The content to be displayed in the pop-up.
    commands
    The collection of commands to show at the bottom of the pop-up.
    includeDefaultCommands
    A value indicating if the default pop-up commands should display.
    Exceptions
    ExceptionDescription
    Popups must be created on the UI thread
    Example
    Show a custom pop-up
    {
      //Create custom popup content
      List<PopupContent> popups =
          [
              new("<b>This text is bold.</b>", "Custom tooltip from HTML string"),
              new(new Uri("https://www.esri.com/"), "Custom tooltip from Uri")
          ];
      mapView.ShowCustomPopup(popups);
    }
    Show a custom pop-up using pop-up window properties
    {
      if (mapView == null) return;
    
      //Create custom popup content
      List<PopupContent> popups =
      [
          new("<b>This text is bold.</b>", "Custom tooltip from HTML string"),
              new(new Uri("https://www.esri.com/"), "Custom tooltip from Uri")
      ];
      // Sample code: https://github.com/ArcGIS/arcgis-pro-sdk-community-samples/blob/master/Framework/DynamicMenu/DynamicFeatureSelectionMenu.cs
      var topLeftCornerPoint = new System.Windows.Point(200, 200);
      var popupDef = new PopupDefinition()
      {
        Append = true,      // if true new record is appended to existing (if any)
        Dockable = true,    // if true popup is dockable - if false Append is not applicable
        Position = topLeftCornerPoint,  // Position of top left corner of the popup (in pixels)
        Size = new System.Windows.Size(200, 400)    // size of the popup (in pixels)
      };
      mapView.ShowCustomPopup(popups, null, true, popupDef);
    }
    Show A pop-up With Custom Commands
    {
      //Create custom popup content from existing map member and object id
      List<PopupContent> popups = [new PopupContent(mapMember, objectID)];
    
      //Create a new custom command to add to the popup window
      List<PopupCommand> commands =
      [
        new PopupCommand(
              p => MessageBox.Show(string.Format("Map Member: {0}, ID: {1}", p.MapMember, p.IDString)),
              p => { return p != null; },
              "My custom command",
              System.Windows.Application.Current.Resources["GenericCheckMark16"] as ImageSource),
          ];
    
      mapView.ShowCustomPopup(popups, commands, true);
    }
    Show A Dynamic Pop-up
    public static void ShowDynamicPopup(MapMember mapMember, List<long> objectIDs)
    {
      MapView mapView = MapView.Active;
      if (mapView == null) return;
      //Create popup whose content is created the first time the item is requested.
      var popups = new List<PopupContent>();
      foreach (var id in objectIDs)
      {
        popups.Add(new DynamicPopupContent(mapMember, id));
      }
      mapView.ShowCustomPopup(popups);
    }
    internal class DynamicPopupContent : PopupContent
    {
      public DynamicPopupContent(MapMember mapMember, long objectID)
      {
        MapMember = mapMember;
        IDString = objectID.ToString();
        IsDynamicContent = true;
      }
    
      //Called when the pop-up is loaded in the window.
      protected override Task<string> OnCreateHtmlContent()
      {
        return QueuedTask.Run(() => string.Format("<b>Map Member: {0}, ID: {1}</b>", MapMember, IDString));
      }
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also