Does anybody know how to get the name/value of an AutomationElement of custom control type? Please see the image with the link below. I am interested in getting the name/value of the highlighted AutomationElement that Inspect tool by Microsoft is able to get. I tried checking if the AutomationElement supports IAccessible since from the Inspect tool since IsLegacyIAccessiblePatternAvailableProperty is true. I didn't have much luck with the following snippet of codes and all I got was empty string for all children of the AutomationElement of table Control (the parent of the highlighted AutomationElement in the image). Please advise.
AutomationElement sibling = TreeWalker.RawViewWalker.GetFirstChild(table); while (sibling != null) { if ((Boolean)sibling.GetCurrentPropertyValue(AutomationElementIdentifiers.IsLegacyIAccessiblePatternAvailableProperty)) { var pattern = ((LegacyIAccessiblePattern)sibling.GetCurrentPattern(LegacyIAccessiblePattern.Pattern)); var name = pattern.GetIAccessible().accValue; //allChildren.Add(sibling); if (((string)name).IndexOf(deviceId) != -1) { AutomationElement device = TreeWalker.RawViewWalker.GetPreviousSibling(sibling); if (device != null) { checkBox = TreeWalker.RawViewWalker.GetPreviousSibling(device); break; } } } sibling = TreeWalker.RawViewWalker.GetNextSibling(sibling); }