Creating custom ArcMap TOC views

Table of contents views in ArcMap

The Table Of Contents (TOC) window in ArcMap provides a graphic interface that allows users to interact with the layers in a map. The TOC window is adjacent to the main map window by default and contains a number of different views. These views can be shown one at a time by clicking the icons in the window toolbar at the top of the TOC. ArcMap has the following four TOC views:
  • Drawing order—Used to change the display order of layers
  • Source—Used to view the data source for layers and tables
  • Visibility—Used to view the visibility state of layers
  • Selection—Used to display and interact with the selected map features
The fifth icon displays the TOC Window Options dialog box. See the following screen shot:
Each view is a separate class implementing IContensView3 and is registered to the ESRI Contents Views (ContentsViews) component category. The classes are as follows:
  • TOCDisplayView
  • TOCCatalogView
  • TOCLegendDisplayView
  • TOCLegendSelectionView
The Window Options dialog box shows TOC property pages, which are created as separate classes implementing IComPropertyPage2, IPropertyPage, and IPropertyPageContext. The property pages are registered to the ESRI Contents Window Options Property Pages (ContentsWindowPropertyPages) component category.
The default TOC views cannot be customized aside from the choices in the Window Options dialog box.

Designing a custom TOC view

Create a TOC view only if your customization will directly interact with the layers in the map. If your customization requires a dockable window, use the dockable window framework to host your customization, not a TOC view. Dockable windows can still dock with the TOC window.
A custom TOC view is an application-level customization that affects many parts of the application framework. In general, the customization should not change the default behavior of ArcGIS applications. For more information on general application customization rules, see the Application framework customizations.

Implementing a custom TOC view

The easiest way to create a custom TOC view is via the ArcGIS Add Class Wizard in Visual Studio. To create a custom TOC view class, follow these steps:
  1. In your Visual Studio project, click Project, and click Add New Item. The Add New Item dialog box opens.
  2. In the Categories pane, expand the ArcGIS node, and click Extending ArcObjects.
  3. In the Templates pane, select ArcGIS Class and click Add. The ArcGIS Add Class Wizard opens.
  4. Under Customization Group, select Desktop, then select Application Framework.
  5. Under Base Component, select TOC View (ArcMap) and click Next.
  6. In the Categories pane, check ArcMap Contents View and click Finish.
The Layer filtering TOC view sample shows an implementation of a custom TOC view.

Application state

The application's status can change during the application run time; for example, in response to user events such as opening and loading new documents. You can also change from the map view to the page layout view.
Your TOC view should be robust enough to handle both map and page layout view, opening documents, and the creation of new documents. The TOC view may need to respond to certain events to handle these situations (the appropriate event interfaces may need to be implemented to respond to these changes).

Generic design

The Display and Source TOC views contain functionality that is generic in nature. Each view works for any type of dataset that can be loaded into the document. For example, the Display view can render all the layer properties, such as name, visibility, and symbology, regardless of the type of layer that was added to the map, including any special renderer symbols that have been applied. Furthermore, the views work the same whether or not ArcMap is displaying the data or page layout view.
The Selection view is slightly less generic in nature. It can display any selectable map layer and safely handle or ignore any non-selectable layers.
To avoid adverse behavior in the application, model your view after these generic designs. You must support or safely ignore any layer that can be loaded into ArcMap or opened from within a document. If your TOC iterates the layers in a map, never assume a layer's type.

See Also:

Sample: Layer filtering TOC view

Development licensing Deployment licensing
ArcGIS for Desktop Basic ArcGIS for Desktop Basic
ArcGIS for Desktop Standard ArcGIS for Desktop Standard
ArcGIS for Desktop Advanced ArcGIS for Desktop Advanced