wpf-devexpress-dot-xpf-dot-grid-dot-automation-dot-gridautomationhelper.md
Occurs when a UI Automation value is requested for the focused row or cell.
Namespace : DevExpress.Xpf.Grid.Automation
Assembly : DevExpress.Xpf.Grid.v25.2.dll
NuGet Package : DevExpress.Wpf.Grid.Core
See AddAutomationRequestedHandler(DependencyObject, RoutedEventHandler) and RemoveAutomationRequestedHandler(DependencyObject, RoutedEventHandler).
Handle the AutomationRequested event to override the value announced by screen readers when the target row or cell is focused.
The event exposes the following related data containers for corresponding scenarios:
Row and a row is focused)Cell and a cell is focused)For GridControl and TreeListControl, attach the AutomationRequested event to the View ( TableView, CardView or TreeListView ).
If you use the TreeViewControl, attach the AutomationRequested event directly to the control.
The following code example handles the AutomationRequested event and changes values announced by a screen reader app when the target 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) {
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);
}
}
See Also