ArcGIS Pro 3.2 API Reference Guide
ArcGIS.Desktop.Framework Namespace / Categories Class
Members Example

In This Topic
    Categories Class
    In This Topic
    Retrieves components registered in a category.
    Syntax
    public static class Categories 
    Public MustInherit NotInheritable Class Categories 
    Remarks

    Component categories are defined in DAML. The DAML fragment below shows an example category declaration.

                <categories>
                  <insertCategory id="ProjectContainers"/>
                </categories>
                

    Anyone can then register a component in the category. A component can optionally have a content sub-element where they can define any XML they wish. In the example below, just a few attributes have been added but this can be any XML desired.

                <categories>
                  <updateCategory refID="ProjectContainers">
                    <insertComponent id="MapContainer" className="MapContainer">
                      <content type="Map" displayName="Maps"/>
                    </insertComponent>
                  </updateCategory>
                </categories>
                

    Any DAML command can also be added to a category by using by specifying a categoryRefID in its declaration. In this case, you can also use the content sub-element to define any custom data.

                <button id="openMap" caption="Open" className="Controls.Cut" categoryRefID="ProjectContainers">
                  <content type="Map" displayName="Maps"/>
                </button>
                

    At runtime you can use the GetComponentElements function to retrieve all the components registered in a particular category, including DAML controls. When a ComponentElement is returned, you can call ComponentElement.GetContent to get a Systm.DAML.Linq.XElement representing the content node or use ComponentElement.ReadAttribute to simply read a string attribute. Call ComponentElement.CreateComponent to instantiate a new instance of the component. Note CreateComponent throws an exception when the component is referencing a DAML command.

    Example
    Collection<ArcGIS.Desktop.Framework.ComponentElement> components;
    components = Categories.GetComponentElements("ProjectContainers");
    
    // Check the components
    foreach (ComponentElement component in components)
    {
    string value = component.ReadAttribute("type");
    if (value != key)
    continue;
    
    ProjectItemContainer container = null;
    try
    {
    container = component.CreateComponent() as ProjectItemContainer;
    if (container == null)
    return null;
    .
    .
    .
    Inheritance Hierarchy

    System.Object
       ArcGIS.Desktop.Framework.Categories

    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also