Recently there was a customer who reported an issue (Details

In his application there was a TabItem who's Visibility property was set to Collapsed. Due to this AutomationElement.FromPoint (UIA api) was not able to return correct element(inside the hidden tabitem) from point (and hence codeduitest test was not able to recognize element from point). This looks like some optimization which WPF UIA implementation has when drilling down for element from point.

The workaround is to override the default TabItemAutomationPeer implementation and override few properties so that the drilling works fine. Attached is the custom TabItem class which I wrote to make this possible. You just need to use the TabItemCustom class instead of default TabItem class to achieve this. TabItemCustomPeer is the automationpeer implementation of TabItemCustom. TabItemCustomPeer is the important class which made this possible.