Some controls on the page are not displayed for MS UI Automation

We have an application with StartPage.xaml where the control template for TabControl defines some grids and stack panels. This template has an itemPresenter element in the middle of xaml and a stack panel below it. Although it works great for the user, MS UI automation can only see tabs inside the element’s presenter, and nothing else is defined at the same level in the template. I tried to add a standard button inside the stack panel, which cannot be seen by MS UIA, to check if this problem is related to custom user controls, but this standard button is also not visible for MS UIA. If I use Snoop, I can see all the elements from the template in the snoop tree at the corresponding levels of the template hierarchy. But MS UIA still cannot find them.

What could be wrong with controls that prevent MS UIA from finding them on the page?

+4
source share
1 answer

Finally, I was able to detect the problem. TabControl has been obscured by many different controls, while AutomationPeer has remained the same that knows only about TabItems as children of TabControl. I subclassed TabControl and overridden OnCreateAutomation to create and return my GenericAutomationPeer, which can list all the child UIElements of this control and voila. UIA Verify can now see additional controls from the TabControl template.

An implementation of the GenericAutomationPeer was found here: http://www.colinsalmcorner.com/2011/11/genericautomationpeer-helping-coded-ui.html Many thanks to the author of this article!

+4
source

Source: https://habr.com/ru/post/1483163/


All Articles