In WinForms applications it's possible to name controls for accessibility clients using the Control.AccessibleName
property.
WPF controls are lacking this property, so I'm wondering how I can give an accessible name to controls in an WPF application.
I've read the documentations and I know it all changed with the UIA
but I still can't find a way to change this property. As stated in the doc, there are two required properties :
I can find Automation ID
but not the name. Where is it hidden ?
The AccessibleName property is a label that briefly describes and identifies the object within its container, such as the text in a Button, the name of a MenuItem, or a label displayed next to a TextBox control. For more information about properties of accessible objects, see the "Content of Descriptive Properties.
wpf. The margin property in WPF allows you set spacing between elements in a window. You can assign the margins for the Top, Right, Bottom and Left. Every control that derives from FrameworkElement has this property.
If you do not use (for some reason) Button's Margin property, you can put transparent Separator (Transparent background color) with desired Width (or/and Height) between your controls (Buttons in your case).
AutomationProperties.Name
is the attached property you are looking for.
You can either specify it directly in XAML:
<object AutomationProperties.Name="name" .../>
Or using the getter/setters on AutomationProperties:
using System.Windows.Automation;
...
AutomationProperties.SetName(control, "name");
...or...
control.SetValue(AutomationProperties.NameProperty, "name");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With