Occurs when the menu that contains the multiItem is about to be displayed.

Namespace:  ESRI.ArcGIS.Desktop.AddIns

Assembly:  ESRI.ArcGIS.Desktop.Addins (in ESRI.ArcGIS.Desktop.Addins.dll) Version: 10.0.0.0 (10.0.0.0)

Syntax

C#
protected virtual void OnPopup(
	MultiItem..::.ItemCollection items
)
Visual Basic (Declaration)
Protected Overridable Sub OnPopup ( _
	items As MultiItem..::.ItemCollection _
)
Visual C++
protected:
virtual void OnPopup(
	MultiItem..::.ItemCollection^ items
)

Parameters

items
Type: ESRI.ArcGIS.Desktop.AddIns..::.MultiItem..::.ItemCollection

The multiItem collection.

Remarks

OnPopup provides a collection of items that will make up the multiItem. Override OnPopup method to add items to the multiItem collection.

Examples

The code below shows an implementation of a multiItem that list all of the feature layers in the current map. Clicking on each item makes the map zoom to the corresponding layer.
CopyC#
public class ZoomToLayerMultiItem : ESRI.ArcGIS.Desktop.AddIns.MultiItem
{
  protected override void OnClick(Item item)
  {
    int index = this.IndexOf(item);
    System.Diagnostics.Debug.WriteLine("The index of the clicked item is " + index.ToString());
    ESRI.ArcGIS.Carto.IMap map = ArcMap.Document.FocusMap;
    ESRI.ArcGIS.Carto.ILayer layer = item.Tag as ESRI.ArcGIS.Carto.ILayer;
    ESRI.ArcGIS.Geometry.IEnvelope env = layer.AreaOfInterest;
    ArcMap.Document.ActiveView.Extent = env;
    ArcMap.Document.ActiveView.Refresh();

  }

  protected override void OnPopup(ItemCollection items)
  {
    ESRI.ArcGIS.Carto.IMap map = ArcMap.Document.FocusMap;
    for (int i = 0; i < map.LayerCount; i++)
    {
      ESRI.ArcGIS.Carto.ILayer layer = map.get_Layer(i);
      Item item = new Item();
      item.Caption = layer.Name;
      item.Enabled = layer.Visible;
      item.Message = layer.Name;
      item.Tag = layer;
      items.Add(item);
      item.BeginGroup = true;
    }
  }
}
CopyVB.NET
Public Class ZoomToLayerMultiItem
  Inherits ESRI.ArcGIS.Desktop.AddIns.MultiItem
  Protected Overloads Overrides Sub OnClick(ByVal item As Item)
    Dim index As Integer = Me.IndexOf(item)
    System.Diagnostics.Debug.WriteLine("The index of the clicked item is " & index.ToString())
    Dim map As ESRI.ArcGIS.Carto.IMap = ArcMap.Document.FocusMap
    Dim layer As ESRI.ArcGIS.Carto.ILayer = TryCast(item.Tag, ESRI.ArcGIS.Carto.ILayer)
    Dim env As ESRI.ArcGIS.Geometry.IEnvelope = layer.AreaOfInterest
    ArcMap.Document.ActiveView.Extent = env

    ArcMap.Document.ActiveView.Refresh()
  End Sub

  Protected Overloads Overrides Sub OnPopup(ByVal items As ItemCollection)
    Dim map As ESRI.ArcGIS.Carto.IMap = ArcMap.Document.FocusMap
    For i As Integer = 0 To map.LayerCount - 1
      Dim layer As ESRI.ArcGIS.Carto.ILayer = map.get_Layer(i)
      Dim item As New Item()
      item.Caption = layer.Name
      item.Enabled = layer.Visible
      item.Message = layer.Name
      item.Tag = layer
      items.Add(item)
      item.BeginGroup = True
    Next
  End Sub
End Class

See Also