DXAccessible.QueryAccessibleInfo Event
Allows you to supply accessibility information to DevExpress UI elements dynamically.
Namespace: DevExpress.Accessibility
Assembly: DevExpress.Utils.v24.1.dll
NuGet Packages: DevExpress.Utils, DevExpress.Wpf.Core
Declaration
public static event EventHandler<DXAccessible.QueryAccessibleInfoEventArgs> QueryAccessibleInfo
Event Data
The QueryAccessibleInfo event's data class is DXAccessible.QueryAccessibleInfoEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
AccessibleObject | Gets the System.Windows.Forms.AccessibleObject that allows you to return the standard accessibility information about the currently processed UI element. |
DefaultAction | Gets or sets a string that describes the UI element’s default action. |
Description | Gets or sets a string that describes the visual appearance of the currently processed UI element. |
Name | Gets or sets the name of the Accessible Object associated with a UI element. |
Owner | Gets the QueryAccessibleInfoEventArgs.Owner control’s child object that contains the currently processed UI element. |
OwnerControl | Gets the control that contains the currently processed UI element. |
Role | Gets or sets the accessible role of the currently processed UI element. |
The event data class exposes the following methods:
Method | Description |
---|---|
GetDXAccessible<DXAccessible>() |
Returns a BaseAccessible object (or its descendant) that stores additional accessibility information about the currently processed UI element.
|
ToString() | Returns a string representing the current object. |
Remarks
DevExpress controls and components expose AccessibleName
, AccessibleDescription
, and AccessibleRole
properties (for example, BarItem.AccessibleName, BarItem.AccessibleDescription, and BarItem.AccessibleRole) that allow you to explicitly assign accessibility information to most of their UI elements. Accessibility information for some UI elements (for instance, grid cells) is formed automatically, and there are no public properties to override the default accessibility information.
Handle the QueryAccessibleInfo
event to supply/modify the accessibility information for UI elements, regardless of whether they have corresponding public AccessibleName
, AccessibleDescription
, and AccessibleRole
settings. The QueryAccessibleInfo
event fires for each DevExpress UI element that has associated accessibility information when this information is requested by screen readers.
Note
Declare your QueryAccessibleInfo
event handler as a form’s method. For instance, do not use a lambda expression to subscribe to the event in the Program.cs file. Otherwise, the garbage collector may release the memory allocated for your event handler.
You can use the WindowsFormsSettings.DisableAccessibility property to disable the accessibility feature for DevExpress controls.
Example
The following example handles the QueryAccessibleInfo
event to modify the default value of the AccessibleName
setting for cells in DevExpress grid controls. The new value is formed as a column’s caption followed by the “cell” word.
using DevExpress.Accessibility;
using static DevExpress.XtraGrid.Accessibility.GridViewAccessibleObject.GridViewDataPanel;
public Form1() {
InitializeComponent();
DXAccessible.QueryAccessibleInfo += DXAccessible_QueryAccessibleInfo;
}
private void DXAccessible_QueryAccessibleInfo(object sender, DXAccessible.QueryAccessibleInfoEventArgs e) {
if (e.Role == AccessibleRole.Cell) {
GridCellAccessibleObject cellAccessible = e.GetDXAccessible<GridCellAccessibleObject>();
if (cellAccessible != null) {
e.Name = cellAccessible.Column.Caption + " cell";
}
}
}
Example
The following QueryAccessibleInfo
event handler supplies the AccessibleName
and AccessibleDescription
settings for tiles in a TileControl.
public Form1() {
InitializeComponent();
DXAccessible.QueryAccessibleInfo += DXAccessible_QueryAccessibleInfo;
}
private void DXAccessible_QueryAccessibleInfo(object sender, DXAccessible.QueryAccessibleInfoEventArgs e) {
if (e.Role == AccessibleRole.ListItem && e.OwnerControl == tileControl1) {
TileItem item = e.Owner as TileItem;
if (item != null && item.Elements.Count > 1) {
e.Name = item.Elements[0].Text;
e.Description = item.Elements[1].Text;
}
}
}