Share via


UI Automation Support for the DataItem Control Type

This topic provides information about Microsoft UI Automation support for the DataItem control type.

An entry in a Contacts list is an example of a data item control. A data item control contains information that is of interest to an end user. It is more complicated than the simple list item because it contains richer information.

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

This topic contains the following sections.

  • Required UI Automation Tree Structure
  • Required UI Automation Properties
  • Required UI Automation Control Patterns
  • Working with DataItems in Large Lists
  • Required UI Automation Events
  • DataItem Control Type Example
  • Related Topics

Required UI Automation Tree Structure

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

Control View Content View
  • DataItem
    • Varies (0 or more; can be structured in hierarchy)
  • DataItem
    • Varies (0 or more; can be structured in hierarchy)

A data item element in a data grid can host a variety of objects, including another layer of data items, or specific grid elements such as text, images, or edit controls. If the data item element has a specific object role, the element should be exposed as a specific control type; for example, a ListItem control type for a selectable data item in the grid.

Required UI Automation Properties

The following table lists the UI Automation properties whose value or definition is especially relevant to the DataItem control type. For more information about UI Automation properties, see UI Automation Properties for Clients.

UI Automation Property Value Notes
UIA_AutomationIdPropertyId See notes. The value of this property needs to be unique across all controls in an application.
UIA_BoundingRectanglePropertyId See notes. The outermost rectangle that contains the whole control.
UIA_ClickablePointPropertyId See notes. Supported if there is a bounding rectangle. If not every point within the bounding rectangle is clickable, and you perform specialized hit testing, override and provide a clickable point.
UIA_ControlTypePropertyId DataItem This value is the same for all UI frameworks.
UIA_IsContentElementPropertyId TRUE The data item control must always be content.
UIA_IsControlElementPropertyId TRUE The data item control must always be a control.
UIA_IsKeyboardFocusablePropertyId See notes. If the control can receive keyboard focus, it must support this property.
UIA_ItemStatusPropertyId See notes. If the control contains status that is being updated dynamically, this property must be supported so that an assistive technology can receive updates when the status of the element changes.
UIA_ItemTypePropertyId See notes. This is the string value that conveys to the end user the underlying object that the item represents. Examples include "Media File" and "Contact".
UIA_LabeledByPropertyId Null Data item controls do not have a static text label.
UIA_LocalizedControlTypePropertyId See notes. Localized string corresponding to the DataItem control type. The default value is "data item" for en-US or English (United States).
UIA_NamePropertyId See notes. The data item control always contains a primary text element that relates to what the user would associate as the most semantic identifier for the item.

Required UI Automation Control Patterns

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

Control Pattern/Pattern Property Support/Value Notes
IExpandCollapseProvider Depends If the data item can be expanded or collapsed to show and hide information, the ExpandCollapse control pattern must be supported.
IGridItemProvider Depends Data items will support the Grid Item control pattern when a collection of data items is available within a container that can be spatially navigated item-to-item.
IScrollItemProvider Depends All data items support the ability to be scrolled into view with the Scroll Item control pattern when their data container has more items than can fit on the screen.
ISelectionItemProvider Yes All data items must support the Selection Item control pattern to indicate when the item is selected.
ITableItemProvider Depends If the data item is contained within a Data Grid control type that has a header element, it should support this pattern.
IToggleProvider Depends If the data item contains a state that can be cycled through.
IValueProvider Depends If the data item's primary text is editable, the Value control pattern must be supported.

Working with DataItems in Large Lists

Because large lists are often virtualized within UI frameworks to assist in performance, a UI Automation client cannot use the UI Automation query feature to search the contents of the full tree in the same way that it can in other item containers. A client should scroll the item into view (or expand the control to show all available options) prior to accessing the full set of information from the data item.

When calling IUIAutomationElement::SetFocus on the UI Automation element for the data item, Microsoft Windows Explorer returns successfully and causes focus to be set to the Edit control within the data item subtree.

Required UI Automation Events

The following table lists the UI Automation events that data item controls are required to support. For more information on events, see UI Automation Events Overview.

UI Automation Event Notes
UIA_AutomationFocusChangedEventId None
UIA_BoundingRectanglePropertyId property-changed event. None
UIA_ExpandCollapseExpandCollapseStatePropertyId property-changed event. If the control supports the ExpandCollapse control pattern, it must support this event.
UIA_IsEnabledPropertyId property-changed event. If the control supports the IsEnabled property, it must support this event.
UIA_IsOffscreenPropertyId property-changed event. If the control supports the IsOffscreen property, it must support this event.
UIA_Invoke_InvokedEventId If the control supports the Invoke control pattern, it must support this event.
UIA_NamePropertyId property-changed event. None
UIA_SelectionItem_ElementAddedToSelectionEventId If the control supports the SelectionItem control pattern, it must support this event.
UIA_SelectionItem_ElementRemovedFromSelectionEventId If the control supports the SelectionItem control pattern, it must support this event.
UIA_SelectionItem_ElementSelectedEventId If the control supports the SelectionItem control pattern, it must support this event.
UIA_StructureChangedEventId None
UIA_ToggleToggleStatePropertyId property-changed event. If the control supports the Toggle control pattern, it must support this event.
UIA_ValueValuePropertyId property-changed event. If the control supports the Value control pattern, it must support this event.

DataItem Control Type Example

The following image illustrates a DataItem control type in a List View control.

List View control with DataItem control type

The control view and the content view of the UI Automation tree that pertains to the data item control is displayed below. The control patterns for each automation element are shown in parentheses. The Group "Contoso" is also part of the grid of the Data Grid host control. For an example of a higher level grid structure, see DataGrid Control Type Example.

UI Automation Tree - Control View UI Automation Tree - Content View
  • Group "Contoso" (Table, Grid)
    • DataItem "Accounts Receivable.doc" (TableItem, GridItem, SelectionItem, Invoke)
      • Image "Accounts Receivable.doc"
      • Edit "Name" (TableItem, GridItem, Value "Accounts Receivable.doc")
      • Edit "Date modified" (TableItem, GridItem, Value "8/25/2006 3:29 PM")
      • Edit "Size" (GridItem, TableItem, Value "11.0 KB")
    • DataItem "Accounts Payable.doc" (TableItem, GridItem, SelectionItem, Invoke)
      • ...
  • Group "Contoso" (Table, Grid)
    • DataItem "Accounts Receivable.doc" (TableItem, GridItem, SelectionItem, Invoke)
      • Image "Accounts Receivable.doc"
      • Edit "Name" (TableItem, GridItem, Value "Accounts Receivable.doc")
      • Edit "Date modified" (TableItem, GridItem, Value "8/25/2006 3:29 PM")
      • Edit "Size" (GridItem, TableItem, Value "11.0 KB")
    • DataItem "Accounts Payable.doc" (TableItem, GridItem, SelectionItem, Invoke)
      • ...

If a grid represents a list of selectable items, the corresponding UI elements can be exposed with the ListItem control type instead of the DataItem control type. In the preceding example, the DataItem elements ("Accounts Receivable.doc" and "Accounts Payable.doc") under Group ("Contoso") can be improved by exposing them as ListItem control types because that type already supports the SelectionItem control pattern.