Back to Devexpress

RowAutomationEventArgs Class

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

latest3.5 KB
Original Source

RowAutomationEventArgs Class

Stores data for the AutomationRequested attached event when the target row, group row, or detail row is focused.

Namespace : DevExpress.Xpf.Grid.Automation

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

NuGet Package : DevExpress.Wpf.Grid.Core

Declaration

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

Remarks

Use the RowAutomationEventArgs class to read or modify values announced by screen readers when the target row, group row, or detail row is focused.

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

Example

The following code example handles the AutomationRequested event and changes values announced by a screen reader app when the target 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) {
    if (e is RowAutomationEventArgs rowArgs) {
        var grid = rowArgs.DataControl as GridControl;
        var view = grid?.View as TableView;
        if (view == null)
            return;

        // Skip special rows
        if (rowArgs.RowHandle == DataControlBase.NewItemRowHandle ||
            rowArgs.RowHandle == DataControlBase.InvalidRowHandle)
            return;

        // "Header1 Value1, Header2 Value2, ..."
        var parts = view.VisibleColumns.Select(c => {
            var header = c.HeaderCaption ?? c.FieldName;
            var value = view.GetCellValue(rowArgs.RowHandle, c);
            return $"{header} {value}";
        });

        e.AutomationValue = string.Join(", ", parts);
    }
}

Inheritance

Object EventArgs RoutedEventArgs AutomationEventArgs RowAutomationEventArgs CellAutomationEventArgs

See Also

RowAutomationEventArgs Members

DevExpress.Xpf.Grid.Automation Namespace