ArcGIS Pro 2.6 API Reference Guide
Categories Class
Members  Example 

ArcGIS.Desktop.Framework Namespace : Categories Class
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 10, Windows 8.1, Windows 7

See Also

Reference

Categories Members
ArcGIS.Desktop.Framework Namespace