UI Automation Support for the TreeItem Control Type

System_CAPS_ICON_note.jpg Note

This documentation is intended for .NET Framework developers who want to use the managed UI Automation classes defined in the System.Windows.Automation namespace. For the latest information about UI Automation, see Windows Automation API: UI Automation.

This topic provides information about UI Automation support for the TreeItem control type. In UI Automation, a control type is a set of conditions that a control must meet in order to use the ControlTypeProperty property. The conditions include specific guidelines for UI Automation tree structure, UI Automation property values and control patterns.

The TreeItem control type represents a node within a tree container. Each node might contain other nodes, called child nodes. Parent nodes, or nodes that contain child nodes, can be displayed as expanded or collapsed.

The following sections define the required UI Automation tree structure, properties, control patterns, and events for the TreeItem control type. The UI Automation requirements apply to all tree item controls, whether Windows Presentation Foundation (WPF), Win32, or Windows Forms.

The following table depicts the control view and the content view of the UI Automation tree that pertains to tree item controls and describes what can be contained in each view. For more information on the UI Automation tree, see UI Automation Tree Overview.

Control ViewContent View

- CheckBox (0 or 1)
- Image (0 or 1)
- Button (0 or 1)
- TreeItem (0 or more)

- TreeItem (0 or more)

Tree item controls can have zero or more tree item children in the content view of the UI Automation tree. If the tree item control has functionality beyond what is exposed in the control patterns listed below, then the control should be based on the Data Item control type.

Collapsed tree items will not display in the control view or content view until they become expanded and visible (or, can be scrolled into view).

The control view can contain additional details for a control, including an associated image or a button. For example, an item in an outline view might contain an image as well as a button to expand or collapse the outline. These detail objects don't appear in the content view because the information is already represented by the parent tree item. Tree items that are scrolled off the screen will appear in both the control and content views of the UI Automation tree and should have the IsOffscreenProperty set to true.

The following table lists the UI Automation properties whose value or definition is especially relevant to list controls. For more information on UI Automation properties, see UI Automation Properties for Clients.

UI Automation PropertyValueNotes
AutomationIdPropertySee notes.The value of this property needs to be unique across all controls in an application.
BoundingRectanglePropertySee notes.The outermost rectangle that contains the whole control.
ClickablePointPropertySee notes.This property must return a location of the item that will cause the item to change selection state or become focused.
ControlTypePropertyTreeItemThis value is the same for all UI frameworks.
IsContentElementPropertyTrueThe list control is always included in the content view of the UI Automation tree.
IsControlElementPropertyTrueThe list control is always included in the control view of the UI Automation tree.
IsOffscreenPropertySee notes.This property is set to indicate when a tree item control is scrolled off the screen.
IsKeyboardFocusablePropertySee notes.If the control can receive keyboard focus, it must support this property.
ItemTypePropertySee notes.If the tree item control uses a visual icon to indicate that is a particular type of object, then this property must be supported and indicate what the object is.
LabeledByPropertyNullTree item controls are self-labeling.
LocalizedControlTypeProperty"tree item"Localized string corresponding to the TreeItem control type.
NamePropertySee notes.This property exposes the text displayed for each tree item control.

The following table lists the UI Automation control patterns required to be supported by list controls. For more information on control patterns, see UI Automation Control Patterns Overview.

Control Pattern/Pattern PropertySupport/ValueNotes
IInvokeProviderDependsImplement this control pattern if the tree item has a separate, actionable command.
IExpandCollapseProviderYesAll tree items can be expanded or collapsed.
ExpandCollapseStateExpanded, Collapsed, or Leaf NodeTree items will be leaf nodes when they are not expanded or collapsed.
IScrollItemProviderDependsImplement this control pattern if the tree container supports the Scroll control pattern.
ISelectionItemProviderDependsImplement this control pattern if it is possible to have an active selection that is maintained when the user returns to the tree container.
SelectionContainerYesThis property will expose the same container for all items within the container.
IToggleProviderDependsImplement this control pattern if the tree item has an associated check box.

The following table lists the UI Automation events required to be supported by all tree item controls. For more information about events, see UI Automation Events Overview.

UI Automation EventSupportNotes
BoundingRectangleProperty property-changed event.RequiredNone
IsEnabledProperty property-changed event.RequiredNone
IsOffscreenProperty property-changed event.RequiredNone
ItemStatusProperty property-changed event.DependsNone
NameProperty property-changed event.RequiredNone
ExpandCollapseStateProperty property-changed event.RequiredNone
CurrentViewProperty property-changed event.DependsNone
ToggleStateProperty property-changed event.DependsNone
ValueProperty property-changed event.DependsNone

UI Automation Control Types Overview
UI Automation Overview