Back to Devexpress

AutomationEventArgs Class

wpf-devexpress-dot-xpf-dot-grid-dot-automation.md

latest4.4 KB
Original Source

AutomationEventArgs Class

Stores data for the AutomationRequested attached event.

Namespace : DevExpress.Xpf.Grid.Automation

Assembly : DevExpress.Xpf.Grid.v25.2.dll

NuGet Package : DevExpress.Wpf.Grid.Core

Declaration

csharp
public class AutomationEventArgs :
    RoutedEventArgs
vb
Public Class AutomationEventArgs
    Inherits RoutedEventArgs

Remarks

Use the AutomationEventArgs class to read or modify values announced by screen readers.

The AutomationRequested attached event allows you to change default values announced by screen reader apps. The event fires when a GridControl (or related controls) requests a UI Automation value for the focused element.

AutomationEventArgs is the base class for the following AutomationRequested event data containers:

RowAutomationEventArgsStores data for the AutomationRequested attached event when the target row, group row, or detail row is focused.CellAutomationEventArgsStores data for the AutomationRequested attached event when the target cell is focused.TreeListNodeAutomationEventArgsStores data for the AutomationRequested attached event when the target tree node is focused.

Example

The following code example handles the AutomationRequested event and changes values announced by a screen reader app when the target cell or row is focused:

xaml
<dxg:GridControl ItemsSource="{Binding Items}">
    <dxg:GridControl.View>
        <dxg:TableView
            x:Name="tableView"
            NavigationStyle="Row"
            dxg:GridAutomationHelper.AutomationRequested="OnAutomationRequested"/>
    </dxg:GridControl.View>
</dxg:GridControl>
csharp
using DevExpress.Xpf.Grid;
using DevExpress.Xpf.Grid.Automation;

void OnAutomationRequested(object sender, AutomationEventArgs e) {
    switch(e) {
        case CellAutomationEventArgs cell:
            // Announce "<Header> <Value>" for the focused cell
            var header = cell.Column.HeaderCaption ?? cell.Column.FieldName;
            e.AutomationValue = $"{header} {cell.Cell.Value}";
            break;

        case RowAutomationEventArgs row:
            // Announce all visible column values for the focused row
            var view = (row.DataControl as GridControl)?.View as TableView;
            if(view != null) {
                var parts = view.VisibleColumns
                    .Select(c => $"{c.HeaderCaption ?? c.FieldName} {view.GetCellValue(row.RowHandle, c)}");
                e.AutomationValue = string.Join(", ", parts);
            }
            break;
    }
}

Inheritance

Object EventArgs RoutedEventArgs AutomationEventArgs RowAutomationEventArgs

TreeListNodeAutomationEventArgs

CellAutomationEventArgs

See Also

AutomationEventArgs Members

DevExpress.Xpf.Grid.Automation Namespace