Back to Devexpress

CellAutomationEventArgs Class

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

latest3.1 KB
Original Source

CellAutomationEventArgs Class

Stores data for the AutomationRequested attached event when the target cell is focused.

Namespace : DevExpress.Xpf.Grid.Automation

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

NuGet Package : DevExpress.Wpf.Grid.Core

Declaration

csharp
public class CellAutomationEventArgs :
    RowAutomationEventArgs
vb
Public Class CellAutomationEventArgs
    Inherits RowAutomationEventArgs

Remarks

Use the CellAutomationEventArgs class to read or modify values announced by screen readers when the target cell is focused.

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

Example

The following code example handles the AutomationRequested event and changes values announced by a screen reader app when the target cell 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) {
    if (e is CellAutomationEventArgs cellArgs) {
        // "<Header> <Value>" — for example: "Unit Price 12.30"
        var header = cellArgs.Column.HeaderCaption ?? cellArgs.Column.FieldName;
        var valueText = cellArgs.Cell.Value?.ToString() ?? string.Empty;

        e.AutomationValue = $"{header} {valueText}";
    }
}

Inheritance

Object EventArgs RoutedEventArgs AutomationEventArgs RowAutomationEventArgs CellAutomationEventArgs

See Also

CellAutomationEventArgs Members

DevExpress.Xpf.Grid.Automation Namespace