Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF equivalent of the AccesibleName property

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 :

  • Name
  • Automation ID

I can find Automation ID but not the name. Where is it hidden ?

like image 243
phadaphunk Avatar asked Feb 21 '13 15:02

phadaphunk


People also ask

What is accessible name in C#?

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.

What is margin in WPF?

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.

How do you add a space between two controls in WPF?

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).


1 Answers

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");
like image 89
BrendanMcK Avatar answered Oct 22 '22 02:10

BrendanMcK