Skip to main content
All docs
V25.2
  • GridAutomationHelper Class

    Exposes an attached routed event that allows you to customize UI Automation values for DevExpress WPF data controls.

    Namespace: DevExpress.Xpf.Grid.Automation

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

    Declaration

    public class GridAutomationHelper

    Remarks

    Handle the AutomationRequested attached event to replace default values announced by screen readers for focused elements.

    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:

    <dxg:GridControl ItemsSource="{Binding Items}">
        <dxg:GridControl.View>
            <dxg:TableView
                x:Name="tableView"
                NavigationStyle="Row"
                dxg:GridAutomationHelper.AutomationRequested="OnAutomationRequested"/>
        </dxg:GridControl.View>
    </dxg:GridControl>
    
    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
    GridAutomationHelper
    See Also