ArcGIS Pro 2.9 API Reference Guide
DynamicMenu Class
Members  Example 

ArcGIS.Desktop.Framework.Contracts Namespace : DynamicMenu Class
Represents a menu that is populated at run-time. This is an abstract class.
Syntax
public abstract class DynamicMenu : PlugIn, System.ComponentModel.INotifyPropertyChanged  
Public MustInherit Class DynamicMenu 
   Inherits PlugIn
   Implements System.ComponentModel.INotifyPropertyChanged 
Remarks

Unlike declaratively defined menus, dynamic menus are populated at run-time. Derived classes must add items in their OnPopup override which is invoked before the menu opens. Dynamic menus may contain simple items consisting of a caption and image, or references to existing DAML controls including other dynamic menus. The OnClick override is invoked with the specified index when an item is clicked. All menu items are cleared after the popup closes.

Dynamic menus can reside directly on the ribbon or on other menus. If the dynamic menu is on a menu and the inline attribute is set to true, the items will be added directly onto the hosting menu instead of being added to a pull-right submenu.

Declaring Dynamic menus in DAML:

            <dynamicMenu caption="Acme Menu " 
                         className="DynoMenu" 
                         id="acme_dynoMenu" 
                         largeImage="pack://application:,,,/ProTestApp;component/Images/MenuImage32.png" 
                         smallImage="pack://application:,,,/ProTestApp;component/Images/MenuImage16.png" >
              <tooltip heading="Heading" image="pack://application:,,,/Acme;component/Images/MenuImage16.png">Some text</tooltip>
            </dynamicMenu>
            

DAML attributes
assembly Assembly name if not in the default assembly.
caption The heading.
categoryRefID Adds control to a specific component category.
className Required class identifier. Optionally include namespace if not in default namespace.
condition Automatically disable the button if the condition is not satisfied.
disableIfBusy Automatically disable the button if the application is busy. Default true.
extendedCaption A more descriptive title.
id Required identifier.
largeImage Image (32x32) used when button is large size.
publicKeyToken The necessary public key token if the assembly is strongly named.
smallImage Image (16x16) used when button is small and middle size.
version The version of the dll if the assembly is strongly named.

Example
internal sealed class DynoMenu : ArcGIS.Desktop.Framework.Contracts.DynamicMenu
{
  internal delegate void MathAction(double number);
            
  protected override void OnPopup()
  {
    double angle = 28.0;
            
    MathAction action = Test;
            
    this.Add("item 1", @"pack://application:,,,/Images/Image1.png", true, true, false, action, angle);
    this.Add("item 2", @"pack://application:,,,/Images/Image2.png");
    this.AddSeparator();
    this.AddReference("acme_basicButton");
    this.AddReference("acme_basicMenu");
    this.AddReference("acme_basicGallery");
  }
            
  protected override void OnClick(int index)
  {
    switch (index)
    {
      case 1:
        System.Windows.MessageBox.Show("2nd item");
        break;
    }
  }
            
  private void Test(double angle)
  {
    System.Windows.MessageBox.Show(angle.ToString());
  }
}
Inheritance Hierarchy

System.Object
   ArcGIS.Desktop.Framework.Contracts.PropertyChangedBase
      ArcGIS.Desktop.Framework.Contracts.PlugIn
         ArcGIS.Desktop.Framework.Contracts.DynamicMenu

Requirements

Target Platforms: Windows 11, Windows 10, Windows 8.1

See Also

Reference

DynamicMenu Members
ArcGIS.Desktop.Framework.Contracts Namespace